I've written the following code:
//--a.cpp--//
#include <stdio.h>
class A
{
public:
void bar();
virtual void foo()=0;
};
class B: public A
{
public:
void foo()
{
A::bar();
}
}
int main()
{
B *b= new B();
b->foo();
return 0;
}
//--b.cpp--//
#include <stdio.h>
class A
{
public:
void bar()
{
printf("class A");
}
}
Now I'm comipilng and linking this modules as follow:
g++ -c a.cpp
g++ -c b.cpp
g++ -o bin a.o b.o
But the undefined reference error
is raised by linker. I don't understand, why?