I have a solution created using visual studio 2008 named, "Solution", and i have two projects in that solution, project "A" and project "B". when 开发者_如何学Pythoni do a thing like below it shows fatal errors in the bottom. I have given in project A->properties->Additional include Directries as ../B
project B
B.h
#include <iostream>
using namespace std;
class B
{
public:
B();
~B();
};
B.cpp
#include "B.h"
B::B()
{
}
B::~B()
{
}
project A
A.h
#include <iostream>
using namespace std;
class A
{
public:
A();
~A();
};
A.cpp
#include "A.h"
#include "B.h"
A::A()
{
B b;
}
A::~A()
{
}
Main.cpp in project A
#include "B.h"
int main()
{
B b;
system("pause");
}
when i run it says
Error 3 fatal error LNK1120: 2 unresolved externals H:\Sol\Debug\A.exe
Error 2 error LNK2001: unresolved external symbol "public: __thiscall B::B(void)" (??0B@@QAE@XZ) A.obj
Error 1 error LNK2001: unresolved external symbol "public: __thiscall B::~B(void)" (??1B@@QAE@XZ) A.obj
It doesn't look like you are exporting class B out of project B. So project A sees the declaration of class B but can't find its implementation. What does project B build?
精彩评论