about inheritance

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

Assume we have a base class called Freight cars and two derived classes
called
Tanker and Boxcar.

Now to my question when the Tanker use base c-tor and plases some value
there will
these be overwritten when Boxcar use base c-tor and place some other value
there.

I assume that when Tanker use base accessing the base class object is
different to the base class object
that Boxcar is accessing when using base.

//Tony
 
Tony Johansson said:
I assume that when Tanker use base accessing the base class object is
different to the base class object
that Boxcar is accessing when using base.

That is correct. They are different instances.

The opposite would be static members. In this case, the single member would
be shared across all instances of FreightCar or any class deriving from it.

-- Alan
 
Back
Top