Multiple Inheritance in C++
In C++ programming, a class can be derived from more than one parents. For example: A classRectangle is derived from base classes Area and Circle.
Source Code to Implement Multiple Inheritance in C++ Programming
#include<iostream.h>
#include<conio.h>
class first
{
int a;
public:
void get()
{
cin>>a;}
int disp()
{return a;}
};
class second
{
int b;
public:
void getsec(){
cin>>b;
}
int dispsec()
{
return b;}
};
class third:public first,public second
{
public:
void getfinal()
{
get();
getsec();
}
void dispfinal()
{
cout<<"ans="<<disp()+dispsec();
}
};
main()
{
third t1;
t1.getfinal();
t1.dispfinal();
getch();
}
multiple inheritancs
Reviewed by Shobhit Goel
on
May 05, 2015
Rating:
No comments:
Post a Comment