Question
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
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
Answer: Option B
Was this answer helpful ?
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 ?
More Questions on This Topic :
Question 3.
How many kinds of classes are there in c++?
....
Question 4.
What is meant by polymorphism?
....
Submit Solution