C++ Multilevel Inheritance
C++ Multilevel Inheritance
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Multilevel Inheritance
A class can also be derived from one class, which is already derived from another
class.
Example
// Base class (parent)
class MyClass {
public:
void myFunction() {
cout << "Some content in parent class." ;
}
};
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 »
COLOR PICKER
https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp 2/4
1/26/24, 10:23 PM C++ Multilevel Inheritance
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
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
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.
https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp 4/4