Question: Write sequence of constructor calling indicating the type of constructor when lg1 is created in main(). In above scenario base Animal's default constructor is


Write sequence of constructor calling indicating the type of constructor when lg1 is created in main(). In above scenario base Animal's default constructor is called although Animal(x) is specified in Lion and Tiger. What change is needed to call Animal's parameterized constructor? (c) In class Animal you have defined two constructors Animal(int x) {} and Animal() {} You have defined following classes: class Lion: virtual public Animal { public: }; Lion(int x): Animal(x) { } class Tiger: virtual public Animal { public: }; Tiger(int x): Animal(x) { } class Liger: public Tiger, public Lion { public: Liger(int x): Lion(x), Tiger(x) { } }; Now create the Liger object in main int main() { Liger lg1(30); } How many times the Animal constructor will be called when lg1 is created and why?
Step by Step Solution
There are 3 Steps involved in it
When lg1 is created in main the sequence of constructor calling would be as follows 1 Default cons... View full answer
Get step-by-step solutions from verified subject matter experts
