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

标签 c++

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

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/

相关文章:

c++ - 空类的链式继承,还有必要吗?

c++ - C++ 中 <Pointer, String> 的 unordered_map

c++ - 错误: no matching function for call to (unsolvable?)

c++ - 如何在数据返回一次后从类实例中删除数据

c++ - 将类对象指针传递给用于初始化 C++ 的函数

c++ - 具有不同长度的两个 vector 数组的线性插值

c++ - FCGI_SetExitStatus 不起作用

c++ - 如何确定作为对象传递给另一个类的模板类的数据类型

c++ - Windows MFT(媒体基础转换)解码器未返回正确的采样时间或持续时间

c++ - 元编程,试图避免许多特化