[英]I have an error LNK2019: unresolved external symbol error (small amount code to look at)
所以我有一個錯誤,我將其精確定位到此功能。 似乎沒有其他問題。
完整的錯誤行:
word_driver.obj:錯誤LNK2001:未解析的外部符號“ public:類WORD和__thiscall WORD :: operator =(class std :: basic_string,class std :: allocator> const&)”(?? 4WORD @@ QAEAAV0 @ ABV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@@ Z)
WORD us;
us = "abc";
cout<<"Testing operator= by assignment the value of \"abc\" to use\n";
cout<<us;
class WORD
{
public:
WORD & operator=(const string &);
WORD & operator=(const WORD &);
private:
void AddChar(char);
alpha_numeric *front;
};
WORD & WORD::operator=(const WORD & org)
{
alpha_numeric *p;
if (this != &org)
{
if (!Is_Empty())
{
while(front != 0)
{
p = front;
front = front->next;
delete p;
}
}
for(p = org.front; p!=0; p=p->next)
{
AddChar(p->symbol);
}
}
return *this;
}
您缺少WORD const&的operator =重載的定義。 請粘貼導致該編譯器消息的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.