我有一个使用名为“解决方案”的 Visual Studio 2008 创建的解决方案,并且我在该解决方案中有两个项目,项目“ A ”和项目“ B ”。当我做下面这样的事情时,它会在底部显示致命错误。我在项目 A->properties->Additional include Directory as ../B 中给出
项目B
溴化氢
#include <iostream>
using namespace std;
class B
{
public:
B();
~B();
};
B.cpp
#include "B.h"
B::B()
{
}
B::~B()
{
}
项目A
啊
#include <iostream>
using namespace std;
class A
{
public:
A();
~A();
};
A.cpp
#include "A.h"
#include "B.h"
A::A()
{
B b;
}
A::~A()
{
}
项目 A 中的 Main.cpp
#include "B.h"
int main()
{
B b;
system("pause");
}
当我运行它说
错误 3 致命错误 LNK1120: 2 unresolved externals H:\Sol\Debug\A.exe
错误 2 错误 LNK2001: 无法解析的外部符号 "public: __thiscall B::B(void)" (??0B@@QAE@XZ) A.obj
错误 1 错误 LNK2001: 无法解析的外部符号 "public: __thiscall B::~B(void)" (??1B@@QAE@XZ) A.obj