Predict the output for the following program

class LivingThing {
public:
LivingThing(){
cout << "Constructor of LivingThing Class" << endl;
}
~LivingThing(){
cout << "Destructor of LivingThing Class" << endl;
}
};

class Animal : public LivingThing {
public:
Animal(){
cout << "Constructor of Animal Class" << endl;
}
~Animal(){
cout << "Destructor of Animal Class" << endl;
}
};

class Reptile : public LivingThing {
public:
Reptile(){
cout << "Constructor of Reptile Class" << endl;
}
~Reptile(){
cout << "Destructor of Reptile Class" << endl;
}
};

class Snake : public Animal, public Reptile {
public:
Snake(){
cout << "Constructor of Snake Class" << endl;
}
~Snake(){
cout << "Destructor of Snake Class" << endl;
}
};
int main() {
Snake* s = new Snake;
}

Constructor of LivingThing Class Constructor of Animal Class Constructor of LivingThing Class Constructor of Reptile Class Constructor of Snake Class
Constructor of LivingThing Class Constructor of Animal Class Constructor of LivingThing Class Constructor of Reptile Class Constructor of Snake Class Destructor of Snake Class Destructor of Reptile Class Destructor of LivingThing Class Destructor of Animal Class Destructor of LivingThing Class
Constructor of LivingThing Class Constructor of Animal Class Constructor of Reptile Class Constructor of Snake Class
Constructor of LivingThing Class Constructor of Animal Class Constructor of LivingThing Class Constructor of Reptile Class Constructor of Snake Class Destructor of LivingThing Class Destructor of Animal Class Destructor of LivingThing Class Destructor of Reptile Class Destructor of Snake Class
Verified Answer
Correct Option - a

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

Telegram