Question
1.
#include
2.
using namespace std;
3.
class student
4.
{
5.
public:
6.
int rno , m1 , m2 ;
7.
void get()
8.
{
9.
rno = 15, m1 = 10, m2 = 10;
10.
}
11.
};
12.
class sports
13.
{
14.
public:
15.
int sm;
16.
void getsm()
17.
{
18.
sm = 10;
19.
}
20.
};
21.
class statement:public student,public sports
22.
{
23.
int tot,avg;
24.
public:
25.
void display()
26.
{
27.
tot = (m1 + m2 + sm);
28.
avg = tot / 3;
29.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class student
4.
{
5.
public:
6.
int rno , m1 , m2 ;
7.
void get()
8.
{
9.
rno = 15, m1 = 10, m2 = 10;
10.
}
11.
};
12.
class sports
13.
{
14.
public:
15.
int sm;
16.
void getsm()
17.
{
18.
sm = 10;
19.
}
20.
};
21.
class statement:public student,public sports
22.
{
23.
int tot,avg;
24.
public:
25.
void display()
26.
{
27.
tot = (m1 + m2 + sm);
28.
avg = tot / 3;
29.
cout
Answer: Option B
Was this answer helpful ?
In this program, We are calculating the total and average marks of a student by using multiple inheritance.
Output:
$ g++ mul1.cpp
$ a.out
3010
Was this answer helpful ?
More Questions on This Topic :
Question 5.
What is meant by multiple inheritance?
....
Submit Solution