C++ Multiple Inheritance
The process of creating a derived class from more than one existing base class is called multiple inheritance.
Example:
#include <iostream>
using namespace std;
class A // base class
{
public:
int i=10;
};
class B // base class
{
public:
int j=5;
};
class C: public A,public B // derived class
{
public:
void show(){
cout << "Addition Of Two Number is: "<< i+j << endl;
}
};
int main() {
C c;
c.show();
return 0;
}
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.