Consider the following architecture:
class A //abstract interface
{
public:
virtual void f() = 0;
};
class AA : public A //abstract interface
{
public:
virtual void g() = 0;
};
class AAA : public AA //abstract interface
{
public:
virtual void h() = 0;
};
class B : public A // implementation class
{
public:
void f() override {};
};
class BB : public B, public AA {}; // implementation class
{
public:
void g() override {};
};
class BBB : public BB, public AAA {}; // implementation class
{
public:
void h() override {};
};
As such, BB
and BBB
are virtual classes, because f is not overridden by BB, and neither f nor g are by BBB. My wish is to be able to instantiate BB and BBB (so that BB and BBB use the override of f defined by B, and BBB uses the override of g defined by BB).
The question is: which inheritance relationships should be marked as virtual
to instantiate BB
and BBB
?
The inheritance diagram should ideally look like this:
A
|\
| \
| \
AA B
| \ |
| \ |
AAA BB
\ |
\ |
BBB
The idea behind this design is that A, AA and AAA are interfaces describing incremental feature levels. B, BB and BB are one corresponding incremental implementation. (So that BB for instance defines everything needed by AA, and also features what's in B)