about inheritance

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
 
A

Alan Pretre

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top