<分区>
简单地说:
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
为什么?
<分区>
简单地说:
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/