Page 1 of 1

What is the output of the following program? Carefully note the placement of the virtual keyword. Elass Pet{ public: Pet

Posted: Fri Apr 29, 2022 8:03 am
by answerhappygod
What Is The Output Of The Following Program Carefully Note The Placement Of The Virtual Keyword Elass Pet Public Pet 1
What Is The Output Of The Following Program Carefully Note The Placement Of The Virtual Keyword Elass Pet Public Pet 1 (65.14 KiB) Viewed 20 times
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