Aim: Write a
program to demonstrate the use of multiple inheritance.
Ans:
#include<iostream.h>
#include<conio.h>
class A
{
protected:
int
a;
public:
void
enter()
{
clrscr();
cout<<"Enter
english marks: \n";
cin>>a;
}
};
class B
{
protected:
int
b;
public:
void
enter1()
{
cout<<"Enter
maths marks: \n";
cin>>b;
}
};
class C
{
protected:
int
c;
public:
void
enter2()
{
cout<<"Enter
computer marks: \n";
cin>>c;
}
};
class get:public A,public B,public C
{
public:
int
d;
float
e;
void
get1()
{
d=a+b+c;
e=d/3;
cout<<"Total
marks="<<d<<"\n";
cout<<"Percentage
is="<<e;
}
}o1;
void main()
{
o1.enter();
o1.enter1();
o1.enter2();
o1.get1();
getch();
}
No comments:
Post a Comment