有两个链表:Clist<Ctrain,Ctrain&> TrainList;
Clist<Cstop,Cstop&> StopList;
其中,Ctrain 和Cstop是如下定义的两个类:
class Cstop{
int a;
float b;
}; class Ctrain{
int ID;
Clist<Cstop,Cstop&> stopList;
};
要想使Clist<Cstop,Cstop&> StopList链表成为Clist<Ctrain,Ctrain&> TrainList链表的结点中的数据成员.
以上我定义的Ctrain类编译后是错误的,该怎么定义TrainList链表?
Clist<Cstop,Cstop&> StopList;
其中,Ctrain 和Cstop是如下定义的两个类:
class Cstop{
int a;
float b;
}; class Ctrain{
int ID;
Clist<Cstop,Cstop&> stopList;
};
要想使Clist<Cstop,Cstop&> StopList链表成为Clist<Ctrain,Ctrain&> TrainList链表的结点中的数据成员.
以上我定义的Ctrain类编译后是错误的,该怎么定义TrainList链表?
int a;
float b;
}; class Ctrain{
int ID;
Clist<Cstop*,Cstop*> stopList;
};
tyepdef CList<Cstop*, Cstop*> lstStop;
CList<lstStop*, lstStop* > xxxx; 是CList不是Clist.注意大小写
如:
class Cstop{
int a;
float b;
public :
Cstop(const Cstop &s) {
a = s.a;
b = s.b; } CStop & operator = (const CStop &s) {
a = s.a;
b = s.b;
return *this;
}
};
int a;
float b;
}; typedef vector<Cstop>ListCstop;
class Ctrain{
int ID;
ListCstop stopList;
}; typedef vector<Ctrain>ListCtrain;
(2)if(p)m_trainList.AddTail(*p);
其中,Clist<Cstop*,Cstop*> StopList
在(1)处的错误提示如下:
error C2664: '__thiscall Ctrain::Ctrain(class CString,class CList<class Cstop *,class Cstop *>)' : cannot convert parameter 2 from 'class CList<class Cstop *,class Cstop *>' to 'class CList<class Cstop *,class Cstop *>'
No copy constructor available for class 'CList<class Cstop *,class Cstop *>'重载了Cstop的拷贝构造函数和 = 号,还是出现如上的错误,不知道是什么原因?
怎么重载Ctrain的拷贝构造函数和 = 号?
各位高手请帮忙,我是刚开始学VC的,许多方面还搞不懂。谢谢!
请问这是怎么回事?
请问这是怎么回事?
using namespace std;