What is the difference between protected and private inheritance?


Ans: It is a common practice to inherit a class publicly, for example,

class der : public base

{

—-

} ;

What happens if a class is inherited protectedly?

class der : protected base

{

—-

} ;

In such cases all public and protected member functions become protected in the derived class, whereas, private functions remain private to derived class.

When a class in inherited privately, all the public and protected member functions become private to the derived class.

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers