Dive Deep into CPP : Inheritance and Access Specifier

When a class inherits a base class with private variables, private variable is also inherited but it is invisible to the derived class. We can access the private variables using the public setter and getter method implemented in the base class.
So the size of the derived class will be same of the base class if it doesn’t have any members. It is similar to member functions.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s