我有一个类型节点列表。我想设置一个临时的节点在列表的前面等于节点,如下所示:涉及运算符过载函数的C++链接器错误
class Node
{
public:
Node();
Node& operator = (const Node& n);
};
,但我不断收到一个链接错误:
Linking...
main.obj : error LNK2019: unresolved external symbol "public: class Node & __thiscall Node::operator=(class Node const &)" ([email protected]@[email protected]@@Z) referenced in function "void __cdecl fillScan(int,class std::list >)" ([email protected]@[email protected]@@[email protected]@@@[email protected]@@[email protected]@@Z)
C:\Users\Aaron McKellar\Documents\School Stuff\CS445\Test\Debug\Test.exe : fatal error LNK1120: 1 unresolved externals
提前感谢!
感谢您的回复。我有一段时间没有做过运算符重载。即使浏览了我的书和在线,我仍然遇到了麻烦。 class节点 { public: Node(); int y; 节点运算符=(const的节点& n); }; 节点::节点()//默认构造 { Y = -1;} 节点&节点::运算符=(const的节点&N) { 如果( !这= N) { this.y = NY; } 回报*本; } 我不知道什么是错的,但是当我做this.y IntelliSense不认识到这一点作为一个节点对象。Please help and thanks! – 2010-02-22 00:22:54
1>编译... 1> main.cpp 1> c:\ us ers \ aaron mckellar \ documents \ school stuff \ cs445 \ test \ test \ main.cpp(49):error C2679:binary'!=':没有找到操作符,它需要'const Node'类型的右手操作数没有可接受的转换) 1>可能是'内置C++操作符!=(Node *,Node *)' 1> c:\ program files \ microsoft sdks \ windows \ v6.0a \ include \ guiddef.h (197):或'int operator!=(const GUID&,const GUID&)' 1>尝试匹配参数列表'(Node * const,const Node)' – 2010-02-22 00:23:48
1> c:\ users \ aaron mckellar \ documents \ school stuff \ cs445 \ test \ test \ main.cpp(51):error C2228:'.y'的左边必须有class/struct/union 1> type是'Node * const' 1>打算用' - >'来代替? – 2010-02-22 00:24:21