在.cpp中我是这样使用CList列表变量的:
CList<struct node ,struct node&> L;
struct node *Nn=new (struct node);
我想让这两个变量作为类的成员变量,我该怎么做啊?
结构体在.h中是这样定义的。
typedef struct node{
CString s1;
CString s2;
CString s3;
} Node;
CList<struct node ,struct node&> L;
struct node *Nn=new (struct node);
我想让这两个变量作为类的成员变量,我该怎么做啊?
结构体在.h中是这样定义的。
typedef struct node{
CString s1;
CString s2;
CString s3;
} Node;
typedef struct node{
CString s1;
CString s2;
CString s3;
} Node;class A
{
private:
CList <struct node ,struct node&> L;
struct node *Nn;
};这样不就可以实现了吗?
把CList <struct node ,struct node&> L;放在.h中,会出现如下错误:
see reference to class template instantiation 'CList<struct node,struct node &>' being compiled
在.pp中,*Nn=new (struct node); 会出现如下错误:
use of undefined type 'node'
CString s1;
CString s2;
CString s3;
} node;class A
{
private:
CList <struct node ,struct node&> L;
struct node *Nn;
}; 再试试
CString s1;
CString s2;
CString s3;
} NODE, *PNODE;class A
{
CList <NODE, NODE&> L;
PNODE Nn;
public:
A()
{
Nn = (PNODE)new NODE;
}
};
CString s1;
CString s2;
CString s3;
} node;
// 这样改,更错了!
// 我的结构体引用没有错误的,所有放在函数中运行,都是没有问题的。
struct node *Nn; 把这两句的struct去掉。
结构体声明放在{ }外面,我原想放在外面不是成全局变量了吗,所以没放。
声明改放在{ }外面之后就OK了,但全局变量里也没有该结构体啊,该结构体跑到和类一个级别位置上去了。不明白?