有两个链表: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链表?

解决方案 »

  1.   

    class Cstop{
             int a;
             float b;
           };    class Ctrain{
            int ID;
           Clist<Cstop*,Cstop*> stopList;
          }; 
      

  2.   

    一般链表里面应该放指针的。
    tyepdef CList<Cstop*, Cstop*> lstStop;
    CList<lstStop*, lstStop* > xxxx; 是CList不是Clist.注意大小写
      

  3.   

    为Ctrain定义operator=等(它提示哪个函数不可用,就增加什么函数)。
      

  4.   


    如:
    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;
    }
    };
      

  5.   

    CStop不用重载,要重载CTrain
      

  6.   

    class Cstop{
             int a;
             float b;
           };    typedef vector<Cstop>ListCstop;
        class Ctrain{
            int ID;
           ListCstop stopList;
          };     typedef vector<Ctrain>ListCtrain;
      

  7.   

    (1)Ctrain *p=new Ctrain(trainID, StopList);
    (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的,许多方面还搞不懂。谢谢!
      

  8.   

    "StopList用引用或指针传"具体一点好吗?
      

  9.   

    我按照hxzb7215191(赚钱犹如真挑土,用钱犹如水偷沙) 所说,包括头文件:#include <vector.h>。但出现错误:Cannot open include file: 'vector.h': No such file or directory
    请问这是怎么回事?
      

  10.   

    我按照hxzb7215191(赚钱犹如真挑土,用钱犹如水偷沙) 所说,包括头文件:#include <vector.h>。但出现错误:Cannot open include file: 'vector.h': No such file or directory
    请问这是怎么回事?
      

  11.   

    include <vector>
    using namespace std;