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.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>