Topic: derivation of the same class from two different base classes


Author: O.Levillain@frcl.bull.fr (Olivier Levillain)
Date: 15 Mar 93 16:08:02 GMT
Raw View
Hi all,

  I'm facing the following problem, and I can't find a "good" solution:

class A
{
public:
 virtual f ();
};

class B : public A
{
public:
 virtual f ();  // does something more than A::f()
};

Now, I have a class C :
class C : public ...
{
 // some data
public:
 g() { ...; f(); ... }
};

and I want two C classes (exactly the same ones), say C_A and C_B, where C_A derives fram A and C_B from B.

My problem is: HOW DO I WRITE THIS WITHOUT DUPLICATING THE CODE OF C_A AND C_B ???

I think this is a quite simple situation but i can't find any solution where I could write one time only the code of
g() in order that it calls A::f() in C_A and B::f() in C_B.


 Thamks for any suggestion.


-------- Olivier LEVILLAIN --- Bull S.A. --------------------------------
 DSE-LANG-ESAF               e-mail: O.Levillain@frcl.bull.fr
 Rue Jean-Jaures, F6/1D/05, BP 53    tel: (33-1) 30-80-65-52
 78340 Les Clayes-sous-Bois, France  Fax: (33-1) 30-80-79-50
-------------------------------------------------------------------------