我的定义结构:
struct Unit
{
CString sName;
public:
Unit & operator=(const Unit &other)
{
if (this == &other) {
return *this;
}; sName = other.sName;
return *this;
};
}; struct Group
{
char szKey[GI_M_CRYPTSIZE];
CArray<Uint, Unit&> ary;
public:
Group & operator=(const Group &other)
{
if (this == &other) {
return *this;
}; strcpy(szKey, other.szKey);
ary = other.ary;
return *this;
};
};但是编译有错,为什么?
struct Unit
{
CString sName;
public:
Unit & operator=(const Unit &other)
{
if (this == &other) {
return *this;
}; sName = other.sName;
return *this;
};
}; struct Group
{
char szKey[GI_M_CRYPTSIZE];
CArray<Uint, Unit&> ary;
public:
Group & operator=(const Group &other)
{
if (this == &other) {
return *this;
}; strcpy(szKey, other.szKey);
ary = other.ary;
return *this;
};
};但是编译有错,为什么?
{
if (this == &other) {
return *this;
};/////去掉分号 strcpy(szKey, other.szKey);
ary = other.ary;
return *this;
};
可能错误是:
struct CTmpDiskIDDlg::Unit不是在class CTmpDiskIDDlg中以public方式暴露出来。
导致其它地方不能范围unit的“=”操作符。
{
CString sName;
public:
Unit & operator=(const Unit &other)
{
if (this == &other) {
return *this;
};////去掉; sName = other.sName;
return *this;
};////去掉;
};下同