class CCRecodNotice:public CArray<Notice,Notice&>
{
public:
CCRecodNotice& operator=(const CCRecodNotice & p1d)
{
int n = p1d.GetSize();

this->RemoveAll();

for( int i = 0; i < n; i++ )
{
this->Add( p1d[i] );     //错误发生在这里
}

return *this;
}

friend CArchive& operator<< (CArchive& ar, CCRecodNotice& p1d)
{
int size=p1d.GetSize();
ar<<size;
for(int i=0;i<size;i++)
ar<<p1d[i];
return ar;
}


friend CArchive& operator>> (CArchive& ar, CCRecodNotice& p1d)
{
int size;
ar>>size;
p1d.SetSize(size);
for(int i=0;i<size;i++)
ar>>p1d[i];
return ar;
}
};error C2664: “CArray<TYPE,ARG_TYPE>::Add”: 不能将参数 1 从“const Notice”转换为“Notice &”
1>        with
1>        [
1>            TYPE=Notice,
1>            ARG_TYPE=Notice &
1>        ]
1>        转换丢失限定符因为对重载特别是类的重载不很清楚,请高手帮忙一下,该做改正

解决方案 »

  1.   

    CCRecodNotice& operator=(const CCRecodNotice & p1d) ->CCRecodNotice& operator=(CCRecodNotice & p1d)
      

  2.   

    class CCRecodNotice:public CArray <Notice,Notice&> 将这句改成class CCRecodNotice:public CArray <Notice, const Notice&> 看看。
      

  3.   

    看看MSDN的建议:template < class TYPE, class ARG_TYPE = const TYPE& > 
    class CArray : 
       public CObject
    ARRAY的第二个参数应该是常引用类型,你的方法是错误的,改Notice&为const Notice&