+2 votes
27 views

the class named GrandFather is the top-level-base-class and it is inherited by intermediate-base-class Father, which is in turn is inherited by the class Son, by performing multilevel inheritance. Father and Mother are inherited by multiple inheritance in Son.

Besides this, the class Son also inherits another class Mother, by performing multiple inheritance (as class Son is inheriting from both Father and Mother classes at the same time), which means that -

The privateand members of class GrandFather, Father and Mother are inherited classes, such as their properties - height, eye_color, hair_color.

The publicgetters and setters functions are inherited and have become the public members in the derived class, Son.

The protected member of class Mother is also inherited as protected member in the derived class, Son.

Grandfather 1 Name (Ali) Height, Eye color, Face color Grandfather 2 Name (Asad) Height, Eye color, Face color Father Name (Raza Ali) Height, Eye color, Face color Mother Name (Rabia Asad) Height, Eye color, Face color Son Name (Ahsan Raza) Height, Eye color, Face color

by (485 points)  
edited by | 27 views

1 Answer

+1 vote

Hi there, read bellow

Multilevel Inheritance:

" A class can also be derived from a class, which is already derived from another class. "

Example:

class GrandFather {
  public:
    void myFunction() {
      cout << "I am  grandfather class." ;
    }
};

// Derived class (father)
class Father: public GrandFather {
};

// Derived class ( son )
class Son: public Father {
};

void main() {
  Son Obj;
  Obj.myFunction();

}

Try the above method! Thanks!

by (2.5k points)  
Can you solve this further? Please
Please post your question as a New Post! I shall help you my best!
Thanks!

Related questions

+2 votes
1 answer
+2 votes
1 answer
+1 vote
0 answers
asked Jun 5 by toheed (1.1k points) | 9 views
+1 vote
0 answers
+1 vote
1 answer
+1 vote
1 answer
asked Jun 27 by fatyma Nauman (485 points) | 14 views
+3 votes
0 answers




Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
106 questions
75 answers
36 comments
93 users