What happens when base class is privately inherited by a derived class?

All QuestionsCategory: Cpp LanguageWhat happens when base class is privately inherited by a derived class?
Chetan Shidling Staff asked 5 years ago

I need short information.

1 Answers
Chetan Shidling Staff answered 5 years ago

The following things happens when the base class is privately inherited by a derived class:

  1. Public members of base class become ‘private members’ of the derived class.
  2. Public members of the base class can only be accessed by the member functions of the derived class.
  3. They are inaccessible to the objects of the derived class.

Ex: class marks  : private student