1>d:\program files\microsoft visual studio 2010\vc\atlmfc\include\afxtempl.h(262): error C2248: “CObject::CObject”: 无法访问 private 成员(在“CObject”类中声明)
1>          d:\program files\microsoft visual studio 2010\vc\atlmfc\include\afx.h(534) : 参见“CObject::CObject”的声明
1>          d:\program files\microsoft visual studio 2010\vc\atlmfc\include\afx.h(509) : 参见“CObject”的声明
1>          此诊断出现在编译器生成的函数“CArray<TYPE,ARG_TYPE>::CArray(const CArray<TYPE,ARG_TYPE> &)”中
1>          with
1>          [
1>              TYPE=int,
1>              ARG_TYPE=int &
1>          ]自己写的代码
CArray<int,int &> CPlotChartControl::GetXSeletedIndexs(void)
{
double scaleX = m_rectPlot.Width() / (m_xAxis.fMax - m_xAxis.fMin);
double fxL ;
int max=m_curSelectRect.right;
int min=m_curSelectRect.left;
for(int i=0;i<m_nLen;i++)

        fxL = m_rectPlot.left+(m_pXData[i] - m_xAxis.fMin) *scaleX ; 
if(fxL>min&&fxL<max)
m_selectPointXIndexs.Add(i);
}
return m_selectPointXIndexs;
请大神帮忙

解决方案 »

  1.   

    i的类型不是int &
      

  2.   

    ??具体可以怎么修改??
    CPoint MaximaPoint;
    MaximaPoint.x = static_cast<int>(m_rectPlot.left + (m_pXData[j] - m_xAxis.fMin) * scaleX);
    MaximaPoint.y = static_cast<int>(m_rectPlot.bottom - (m_pYData[j] - m_yAxis.fMin) * scaleY);

    if(!m_selectPointVIndex.IsEmpty())   //查看m_selectPointVIndex是否有重复的索引号
    {
    bool bflags = false;             
    for(int k=0; k<m_selectPointVIndex.GetSize(); k++)
    {
    if(j == m_selectPointVIndex.GetAt(k))
    bflags = true;
    }
    if(bflags)    //有重复序号
    ;
    else          //没有重复序号
    {
    m_selectPoint.Add(MaximaPoint);
            m_selectPointVIndex.Add(j);
    }
    }
    else             //第一次选取的点
    {
    m_selectPoint.Add(MaximaPoint);   //存极值的点坐标
        m_selectPointVIndex.Add(j);       //存极值点的索引号
    }
    Invalidate();
    } 别人程序也这样编译没问题
      

  3.   

    你的 m_selectPointXIndexs怎么定义的
      

  4.   

    CArray<int,int &>  ->CArray<int,int> 
      

  5.   

    CArray<int,int &> m_selectPointXIndexs;// 选取频率的X轴索引这样定义的
      

  6.   

    测试了一下,不会出错
    CArray<int,int &> m_selectPointXIndexs;
    for (int i=1 ;i <3;i++)
    {
    m_selectPointXIndexs.Add(i);
    }
      

  7.   

    CArray
    The CArray class supports arrays that are similar to C arrays, but can dynamically shrink and grow as necessary.template< class TYPE, class ARG_TYPE > class CArray : public CObjectAt a Glance
    Header file: Afxtempl.h 
    Platforms:   
    Versions:  1.0 and later 
    Complete documentation:  Visual C++ documentation 
    See Also
    CArray Member Functions, CArray Operators, CObArray  
    CArray::Add 
    int Add( ARG_TYPE newElement );
    throw( CMemoryException );Return ValueThe index of the added element.ParametersARG_TYPETemplate parameter specifying the type of arguments referencing elements in this array.newElementThe element to be added to this array.ResAdds a new element to the end of an array, growing the array by 1. If SetSize has been used with an nGrowBy value greater than 1, then extra memory may be allocated. However, the upper bound will increase by only 1.Example// example for CArray::Add
    CArray<CPoint,CPoint> ptArray;CPoint pt(10,20);
    ptArray.Add(pt);             // Element 0
    ptArray.Add(CPoint(30,40));  // Element 1
    CArray Overview |  Class Members |  Hierarchy ChartSee Also   CArray::SetAt, CArray::SetAtGrow, CArray::InsertAt, CArray::operator []
      

  8.   

    返回 CArray 需要拷贝构造函数,
    而 CArray 基于 CObject。
    CObject 禁止的。
    她的 拷贝构造函数是私有的。