Question: Question: 1 Consider the following C + + code: #include using namespace std; class Base { public: Base ( ) { cout < < Base

Question: 1
Consider the following C++ code:
#include
using namespace std;
class Base {
public:
Base(){
cout << "Base Constructor" << endl;
}
virtual ~Base(){
cout << "Base Destructor" << endl;
}
};
class Derived : public Base {
public:
Derived(){
cout << "Derived Constructor" << endl;
}
~Derived(){
cout << "Derived Destructor" << endl;
}
};
int main(){
Base* ptr = new Derived();
delete ptr;
return 0;
}
Options:
A)
Copy code
Base Constructor
Derived Constructor
Base Destructor
B)
Copy code
Base Constructor
Derived Constructor
Derived Destructor
Base Destructor
C)
Copy code
Derived Constructor
Base Constructor
Base Destructor
Derived Destructor
D)
Copy code
Derived Constructor
Base Constructor
Derived Destructor
Base Destructor

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!