C++ Programming - Functions - Discussion
Discussion Forum : Functions - Programs (Q.No. 40)
40.
What is correct about the following program?
#include<iostream.h>
class Base
{
int x, y, z;
public:
Base()
{
x = y = z = 0;
}
Base(int xx, int yy = 'A', int zz = 'B')
{
x = xx;
y = x + yy;
z = x + y;
}
void Display(void)
{
cout<< x << " " << y << " " << z << endl;
}
};
class Derived : public Base
{
int x, y;
public:
Derived(int xx = 65, int yy = 66) : Base(xx, yy)
{
y = xx;
x = yy;
}
void Display(void)
{
cout<< x << " " << y << " ";
Display();
}
};
int main()
{
Derived objD;
objD.Display();
return 0;
}
Discussion:
21 comments Page 2 of 3.
Dharamsingh Rajput said:
7 years ago
E is the right option according to me.
ARNAB said:
1 decade ago
DevCpp confirms the answer to be E.
Meghnath malhothra said:
8 years ago
It will produce no.of 66 65 because it is a recursive function calling.
Tushar kumar said:
8 years ago
Yes, the answer is E well executed in the c++ compiler.
Pooja said:
8 years ago
The correct answer is E.
Jitendra said:
8 years ago
The correct answer is E.
Manik said:
8 years ago
The Answer must be E.
Vishii said:
9 years ago
The answer should be 'B'. Can anyone explain why the answer is 'c'?
Naina said:
9 years ago
Can anyone explain properly.
Manjunath said:
1 decade ago
Its a recursive call so it prints 66 65 infinitely.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers