The following code works perfectly fine:
#include "stdafx.h"
class A1
{
public:
virtual void a1() = 0;
};
class B1 : virtual public A1
{
public:
virtual void b1()
{
A1::a1();
}
};
class A1_Impl : virtual public A1
{
public:
virtual void a1() {}
};
class B_Combined : virtual public A1_Impl/*, virtual public B1*/
{
};
int _tmain(int argc, _TCHAR* argv[])
{
B_Combined b;
return 0;
}
After removing /*
and */
the compiler presents the "'B_Combined': inherits 'A1_Impl::A1_Impl::a1' via dominance"
warning. I guess thats okay, because I want B_Combined to inherit the implementation of A1::a1
in A1_Impl
(its the only implementation).
But I also get an error message:
error LNK2001: unresolved external symbol ""public: virtual void __thiscall A1::a1(void)" (?a1@A1@@UAEXXZ)".
I am a bit confused about this. Why doesn't the implementation in A1_Impl work? Deriving B_Combined from B1 should only add a new method b1
calling the implementation of A1::a1
in A1_Impl
.