0% found this document useful (0 votes)
33 views4 pages

C++ Multilevel Inheritance

Uploaded by

ramukaka777787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

C++ Multilevel Inheritance

Uploaded by

ramukaka777787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1/26/24, 10:23 PM C++ Multilevel Inheritance

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

C++ Multilevel Inheritance


❮ Previous Next ❯

Multilevel Inheritance
A class can also be derived from one class, which is already derived from another
class.

In the following example, MyGrandChild is derived from class MyChild (which is


derived from MyClass ).

Example
// Base class (parent)
class MyClass {
public:
void myFunction() {
cout << "Some content in parent class." ;
}
};

// Derived class (child)


class MyChild: public MyClass {
};

// Derived class (grandchild)


class MyGrandChild: public MyChild {
};

int main() {

https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp 1/4
1/26/24, 10:23 PM C++ Multilevel Inheritance

MyGrandChild myObj;
 Tutorials  Exercises 
myObj.myFunction(); Services   Sign Up Log in
return 0;
HTML
 } CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

Try it Yourself »

❮ Previous Log in to track progress Next ❯

COLOR PICKER



https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp 2/4
1/26/24, 10:23 PM C++ Multilevel Inheritance

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

 SPACES UPGRADE AD-FREE

NEWSLETTER GET CERTIFIED

REPORT ERROR

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate

https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp 3/4
1/26/24, 10:23 PM C++ Multilevel Inheritance
XML Examples C# Certificate

 jQuery Examples
Tutorials  Exercises  Services  XML Certificate
 Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

    FORUM ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to
improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our
terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by


W3.CSS.

https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp 4/4

You might also like