Multiple Inheritance in C++
Multiple Inheritance in C++
Multiple Inheritance: In this type of inheritance a single derived class may inherit from two or more than two base classes.
SYNTAX :
class A { ... .. ... }; class B { ... .. ... }; class C: public A,public B { ... ... ... };
CODE :
#include<iostream.h>
class A
{
public:
int a;
void getA()
{
cout<<“Enter an Integer value”<<endl;
cin>>a;
}
};
class B
{
public:
int b;
void getB()
{
cout<<“Enter an Integer value”<<endl;
cin>>b;
}
};
class C:public A,public B
{
public:
int c;
void add()
{
c=a+b;
cout<<a<<“+”<<b<<“=”<<c<<endl;
}
};
int main()
{
C obj;
obj.getA();
obj.getB();
obj.add();
}
OUTPUT :
Enter an Integer
value 12 Enter an
Integer value 13
12+13=25
Topics Covered :
- inheritance in c++
- multiple inheritance in c++
- multiple inheritance in hindi
- types of inheritance
- c++ inheritance
- c++ object oriented programming
Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.
Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.
Social Media Links of Tech DCode :
YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
Instagram : https://www.instagram.com/thetechdcode/
Facebook Page : https://www.facebook.com/thetechdcode
Twitter : https://twitter.com/thetechdcode
Telegram Channel : https://t.me/thetechdcode
Tech DCode Linktree : https://linktr.ee/thetechdcode
My Personal Handles : https://linktr.ee/virtualshivamin
Social Media Links of SHIVAM SINGH (OWNER) :
Instagram : https://www.instagram.com/virtualshivamin/
Facebook Page : https://www.facebook.com/virtualshivamin/
Twitter : https://twitter.com/virtualshivamin/
Personal Linktree : https://linktr.ee/virtualshivamin