I want to move impletation into cpp file, but I am stuck here.
wish your help.
I have 2 class A, and B.
#include "stdafx.h"
class A;
//class B
//{
//public:
// A* a;
// B();
// void Bdosomething();
//};
#include "b.h" // just the above content
//class A
//{
//public:
// B* b;
// A(B* bv);
//
// void Adosomething();
//};
#include "a.h" // just the above content
A::A(B* bv):b(bv){}
inline void A::Adosomething()
{
b->Bdosomething();
}
// move the above para to a.cpp file
B::B(){a = NULL;}
inline void B::Bdosomething()
{
if(!a)
{
a = new A(this);
a->Adosomething();
printf("a set to dosomething\n");
}
}
// move the above para to b.cpp file
int _tmain(int argc, _TCHAR* argv[])
{
B* pB = new B();
pB->Bdosomething();
return 0;
}
this works well, but when I move B's impletation into b.cpp
file, it complaints:
circref error LNK2019: unresolved external symbol "public: void __thiscall
B::Bdosomething(void)" (?Bdosomething@B@@QAEXXZ) referenced in function
_main
circref error LNK2019: unresolved external symbol "public: __thiscall
B::B(void)" (??0B@@QAE@XZ) referenced in function _main
circref fatal error LNK1120: 2 unresolved externals
thanks in advance.