I'm trying to derive a class from two abstract base classes.
#include <stdio.h>
class A
{
public:
virtual void Method(void) = 0;
};
class B
{
public:
virtual void Method(void) = 0;
};
class C: public A, public B
{
public:
virtual void Method(void);
};
void C::A::Method(void)
{
printf("C::A::Method\r\n");
}
void C::B::Method(void)
{
printf("C::B::Method\r\n");
}
C test;
If I try to compile, I get the following error by the linker:
undefined reference to `vtable for C'
If I change the declaration of class C to
class C: public A, public B
{
public:
virtual void A::Method(void);
virtual void B::Method(void);
};
The compiler gives the following errors:
cannot declare member function 'A::Method' within 'C'
cannot declare member function 'B::Method' within 'C'
What I want to achieve is to make C providing an implementation for both abstract interfaces A and B. Does anybody know how to do it right? Thanks.