Topic: Inherited Classes


Author: lynnwood@crash.cts.com (Lynn Wood)
Date: 1995/06/13
Raw View
I have two classes that both are derived from the same base class.
Can I only have one occurance on the base calls.

i.e.

class a : public c
{
}

class b : public c
{
}


cvar = new c(...);

b bvar = new b(); /* some way to pass c*/
a avar = new a(); /* some way to pass a*/

I have found that if you pass c as a param to b's constructor, b's contructor
can call a's constructor as follows

  b::b(c &cvar) : c(cvar)
{}

Problem is this appear to copy b's copy of c from the passed c. Now you have
two identical copies of c, that can be changed independant of each other.
I would like for them to be the same copy.

I hope this is not two confusing of an example, it is hard to illustrate.

Greg