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
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