2. Access specifiers in inheritance #

The protected access specifier #

We know public and private:

Protected: Only child classes can access these members. Simply said, they are like private except that they can be inherited to a derived class.

Protected example: Only vehicles and it’s children can access the vehicle class’s protected parts.

Access specifier mode of inheritance #

As said [[1_Inheritance_-_Concept |earlier]], all members(other than selected exceptions) of the parent class are available in the derived class. But what is happens to their access specifier?

This is specified in the syntax.

The access mode specifies access specifier of the inherited members.

The rule is discussed [[3_Syntax |here]].

What happens to private members of parent class #