Hello,
I'm looking to bounce ideas off of anyone, since mainly the idea of using
Multiple Virtual Inheritance seems rather nutty. I chalk it up to my lack
of C++ Experience.
Here is my scenario...
I have 5 Derived Classes
I have 3 Base Classes
The relationship between Base / Derived is more along the lines of Has-A,
rather than Is-A
Please don't shoot me, still learning here.
Derived Classes:
Class A : private AAA, private BBB
{
public:
void MySay() {};
protected:
virtual void 7_Methods() {}; // Do it My Way Different
virtual void 4_Methods() (); // Do it My Way Different
}
Class B : private AAA, private BBB
{
public:
void MySay() {};
protected:
virtual void 7_Methods() {}; // Do it My Way Slightly Different
virtual void 4_Methods() (); // Do it My Way Slightly Different
}
Class C : private AAA, private BBB
{
public:
void MySay() {};
protected:
virtual void 7_Methods() {}; // Do it My Way Really Different
virtual void 4_Methods() (); // Do it My Way Really Different
}
Class D : private AAA, private CCC
{
public:
void MySay() {};
protected:
virtual void 7_Methods() {}; // Do it My Way Kinda Different
virtual void 3_Methods() (); // Do it My Way Kinda Different
}
Class E : private AAA, private CCC
{
public:
void MySay() {};
protected:
virtual void 7_Methods() {}; // Do it My Way Plain Different
virtual void 3_Methods() (); // Do it My Way Plain Different
}
Base Classes:
Class AAA :
{
protected:
void 17_Methods();
virtual void 7_Methods() = 0; // Implementation I need from Derived
}
Class BBB :
{
void 13_Methods();
virtual void 4_Methods() = 0; // Implementation I need from Derived
}
Class CCC :
{
void 6_Methods();
virtual void 3_Methods() = 0; // Implementation I need from Derived
}
The Reasoning behind this Nightmare:
I have 3 Base Classes primarily with Common Implementation Code.
The UNCOMMON code in the base class is declared to be pure virtuals, so
that when the Base Class makes that particular method call, it will be
over-ridden by the Derived Class (which has the correct implmentation in
that class).
In addition to this problem:
Class BBB and Class CCC, rely on values from Class AAA (That is, the
Derived Class will be passing on values into Class BBB / CCC methods, with
the exception of the Virtual Methods)
I'm sure there is a far better solution, there always is...
and I've thought about Aggregation, but I'm unsure as to how I can get the
same data relationship when I do it the inheritance way.
i.e. Base Pure Virtual Call -Goes to Derived for Implementation.
If anyone can point me in an alternate suggestion, maybe templates instead,
or something... + explanation that'd be great too.
Thanks for all / any help.
It's much Appreciated,
Heinz!