Why we not go for private and protected Inheritance in c++ ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nabeel Nazir
    New Member
    • Aug 2013
    • 5

    #1

    Why we not go for private and protected Inheritance in c++ ?

    Code:
    class A
    {
    Protected:
    void k();
    
    };
    Class B : Private A
    {
    void k();
    };
    //What is wrong in this code of c++, Why we not go for private and protected Inheritance in c++ ?
    Last edited by Rabbit; Aug 29 '13, 05:20 PM. Reason: Fixed code tags
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    In the code sample, the keywords private and protected are not capitalized.

    You use private inheritance to inherit the implementation of a class.

    You use protected inheritance when the base class is incomplete and needs its implementation completed in the derived class. The derived class in this case used to be called a mix-in class.

    Comment

    Working...