Question
1.
#include
2.
using namespace std;
3.
class polygon
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.
class output1
13.
{
14.
public:
15.
void output (int i);
16.
};
17.
void output1::output (int i)
18.
{
19.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class polygon
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.
class output1
13.
{
14.
public:
15.
void output (int i);
16.
};
17.
void output1::output (int i)
18.
{
19.
cout
Answer: Option C
Was this answer helpful ?
Answer:c
Explanation:We are using the multiple inheritance to find the area of rectangle and triangle.
Output:
$ g++ mul.cpp
$ a.out
20
10
Was this answer helpful ?
Submit Solution