求助 关于重载运算符时CLIST的复制
在编写MFC时,由于出现了C2248错误,必须用到类的运算符重载,别人用的是CArray,链接如下:
http://www.cppblog.com/hlong/archive/2007/11/20/37015.html
我用的代码如下
class Equipment
{
public:
CString id;//设备id
CString Vol;//电压等级
CList<CPoint,CPoint&> Out;//设备出线端(1-n个)
CList<Equipment,Equipment&> Connected;//相连设备(1-n个)
Equipment & operator=(const Equipment &t1){
if(this!=&t1)
{
this->id=t1.id;
this->Vol=t1.Vol;
//用循环复制的方法
POSITION pos=t1.Out.GetHeadPosition();
this->Out.RemoveAll();
while(pos!=NULL)
{
this->Out.AddTail(t1.Out.GetNext(pos));
}
//用直接复制的方法
Connected.RemoveAll();
Connected.AddHead(t1.Connected);
}
return *this;
}
};