Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class BaseClass
4.
{
5.
protected:
6.
int i;
7.
public:
8.
BaseClass(int x)
9.
{
10.
i = x;
11.
}
12.
~BaseClass()
13.
{
14.
}
15.
};
16.
class DerivedClass: public BaseClass
17.
{
18.
int j;
19.
public:
20.
DerivedClass(int x, int y): BaseClass(y)
21.
{
22.
j = x;
23.
}
24.
~DerivedClass()
25.
{
26.
}
27.
void show()
28.
{
29.
cout
Options:
A .  3 4
B .  4 3
C .  4
D .  3
Answer: Option B

In this program, We are passing the values and assigning it to i and j and we are printing it.
Output:
$ g++ der1.cpp
$ a.out
4 3



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers