What is the output of the following program? Carefully note the placement of the virtual keyword. Elass Pet{ public: Pet
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What is the output of the following program? Carefully note the placement of the virtual keyword. Elass Pet{ public: Pet
What is the output of the following program? Carefully note the placement of the virtual keyword. Elass Pet{ public: Pet(string n = ***) : name(n){} virtual Pet(){cout<< "Pet dtor"<<endl;} protected: string name; class Dog : public Pet{ public: Dog(string n = "") : Pet(n){} virtual Dog(){cout<<"Dog dtor"<<endl;} int main() { Dog rex("Rex"); Pet& p1 - rex; Pet* p2 - &rex; return; Dog dtor Dog dtor Pet dtor Pet dtor None of these. Pet dtor Dog dtor O Dog dtor Pet dtor
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!