I'm developing in native C++, using visual studio.
I have one project which contains infrastructures - base classes which I want to derive classes from in other projects in the same solution. Say I have a base class in the infrastructres project:
file base.h:
class Base
{
public:
void Foo();
protected:
void Bar();
};
and in another project, a class derived from A, try to call the method bar:
file derived.h:
class Derived : Base
{
public:
void DoSomething();
};
file derived.cpp:
void Derived::DoSomething()
{
Bar();
}
file main.cpp:
void main()
{
Derive d;
d.Foo(); //OK
d.DoSomething(); // Linker error
}
generates the following linker error:
Error 1 error LNK2001: unresolved external symbol "public: virtual void __thiscall Base::Bar(void)" (?Bar@Base@@UAEXXZ) main.obj CplusplusTestProject
What am I doing wrong?