OOAD Princhiples Q/A #3



Question:What is the difference between publicly derived inheritance and privately derived inheritance?

Answer:

Sr. No. Publicly derived inheritance Privately derived inheritance
1 The public derivation of inheritance means that the derived class can access public and protected members of the base class. The private derivation of inheritance means that the derived class can access public and protected members of the base class privately.
2 The public derivation does not change the access specifiers for inherited members in the derived class. They can be inherited further. The inherited members become private in the derived class and they can not be inherited further by any other derived class derived from this derived class.
3 The protected member of base class will act as a protected member in derived class. The protected members of a base class will act as a private member in derived class.
4 The public member of base class will remain public member in derived class. The public members of a base class will act as a private member in derived class.
Advertisements