gpt4 book ai didi

c++ - 未解析的外部符号,尝试修复时遇到问题

转载 作者:行者123 更新时间:2023-11-28 03:07:17 24 4
gpt4 key购买 nike

您好,我从下面的代码中收到此错误:

Error 4 error LNK2019: unresolved external symbol "public: __thiscall Noun::Noun(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Noun@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function "public: __thiscall Dictionary::Dictionary(void)" (??0Dictionary@@QAE@XZ)

我猜这个错误是因为没有声明构造函数Noun(string word, string definition);我也不确定如何声明它以消除错误以便编译我的代码。下面是我的代码。

最佳答案

链接器提示您没有为Noun 的构造函数添加定义。添加它,此错误将得到修复。我相信您只是想在其中调用父级的构造函数,所以也许这可以完成工作:

Noun(string word, string definition) : Word(word, definition) {}

关于c++ - 未解析的外部符号,尝试修复时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19375559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com