Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class poly
4.
{
5.
protected:
6.
int width, height;
7.
public:
8.
void set_values(int a, int b)
9.
{
10.
width = a; height = b;
11.
}
12.
};
13.
class Coutput
14.
{
15.
public:
16.
void output(int i);
17.
};
18.
void Coutput::output(int i)
19.
{
20.
cout
Options:
A .  1212
B .  1210
C .  1010
D .  none of the mentioned
Answer: Option B

In this program, We are calculating the area of rectangle and
triangle by using multilevel inheritance.
$ g++ class1.cpp
$ a.out
1210



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers