C++ - 未解析的外部符号

标签 c++ class linker external-dependencies

<分区>

简单地说:

foo.h:

#include "bar.h"
class foo {
private:
    bar it;
    void DoIt();
}

bar.h:

class bar {
public:
    void Test();
}

foo.cpp:

void foo::DoIt() {
    it.Test();
}

这将导致:

error LNK2001: unresolved external symbol

为什么?

最佳答案

您还没有为 bar::Test() 方法编写代码。

关于C++ - 未解析的外部符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/373762/

相关文章:

C# 在字典中使用类作为对象

c++ - memcpy 或 memmove 会导致复制类出现问题吗?

ios - "dyld: Symbol not found:"静态库中 iOS 6 独有的类

linux - 无法识别共享库文件格式

c++ - 提高 Windows Sleep() 的准确性

c++ - 如何在 C++ 中打印 tchar

c++ - Lambda 捕获子句的问题

c++ - 类似于 boost::multi_index for Python

excel - VBA 对象数据在集合中被覆盖

c - 为什么要多重定义?为什么没有定义其他引用?这真的很基本,我错过了什么?