Predict the output for the following program

class base {
public:
base() {
cout<<"Constructing base \n";
}
~base() {
cout<<"Destructing base \n";
}
};
 
class derived: public base {
public:
derived() {
cout<<"Constructing derived \n";
}
~derived() {
cout<<"Destructing derived \n";
}
};
 
int main(void) {
base* b = new derived;
delete b;
return 0;
}

Constructing base Destructing base
Constructing derived Destructing derived
Constructing base Constructing derived Destructing derived Destructing base
Constructing base Constructing derived Destructing base
Verified Answer
Correct Option - d

To get all Infosys Certified CPP Programmer Exam questions Join Telegram Group https://rebrand.ly/lex-telegram-236dee

Telegram