Jump to content
  • Advertisement
Sign in to follow this  
Tibetan Sand Fox

Is there any practical use of private inheritance ?

This topic is 1991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello there.

 

As asked in topic I wonder if there is any sense of using private inheritance as this:

 

class Foo
{

public:
    void Bar();
};

class Derived : private Foo
{
};

 

 

pretty much means the same as that:

class Foo
{

protected:
    void Bar();
};

class Derived : public Foo
{
};

 

Only difference I see is that I choose if I want public elements of Foo class to be inherited as private or if I'd rather like to inherit them as public, but is that flexibility helpful in any way ? I mean, in my opinion private inheritance could possibly just bring mess and chaos to code, but maybe some people in here had an occasion to find that solution helpful ? Thank you very much in advance.

Share this post


Link to post
Share on other sites
Advertisement
Thank you very much for the answers. That's just what I needed to know. I did some research on my own about the private inheritance and I found quiet few more of the uses of that feature. Actually I could have done that before asking the question, but well, without the questions forum would be quiet empty happy.png

//edit: +1'ed as promised. Edited by Agbahlok

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!