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ย