0

Hi,

I don't get the meaning of this question: change B and C inheritance to public and protected respectively

This are the classes and their inheritances that I have:

class A
{
public: 
    int a;
    A();                //default constructor
    A(int, int, int);   //another constructor
    ~A();               //destructor
    void printA();      //printA
protected: 
    int b;              
private:                    
    int c; 
}; 


class B: public A 
{
public: 
    string e;
    B();                        //default constructor
    B(string, string, string);  //another constrctor
    ~B();                       //destructor
    void printB();              //printB
protected: 
    string f;               
private:                    
    string g; 
};



class C: public B 
{
public: 
    string x;
    C();                        //default constructor
    C(string, string, string);  //another constructor
    ~C();                       //destructor
    void printC();              //printB
protected: 
    string y;               
private:                    
    string z; 
};
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by NathanOliver
0

NathanOliver,

shouldn't it be
class C: protected B

since the question is change B and C inheritance to public and protected respectively. That is just my opinion, I don't know

0

change B and C inheritance to public and protected respectively

This means that B needs to have public inheritance and C needs to have protected inheritance. They still inherate from the same object just the type of inheritance changes

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.