Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

Cpp Programming Quiz 199 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class Base
{
int x, y;
public:
Base()
{
x = y = 0;
}
Base(int xx)
{
x = xx;
}
Base(int p, int q = 10)
{
x = p + q;
y = q;
}
void Display(void)
{
cout<< x << " " << y << endl; } }objDefault(1, 1); class Derived: public Base { Base obj; public: Derived(int xx, int yy): Base(xx, xx + 1) { } Derived(Base objB = objDefault) { } }; int main() { Derived objD(5, 3); Derived *ptrD = new Derived(objD); ptrD->Display();
delete ptrD;
return 0;
}

[A].3 2
[B].8 3
[C].11 6
[D].11 10 

Answer: Option C