Question: create an Animal class that has a single private integer member called legs. Create a default constructor (that sets legs to 4) and a constructor

create an Animal class that has a single private integer member called legs. Create a default constructor (that sets legs to 4) and a constructor with parameters (that checks to make sure that legs is set between 0 and 4, and defaults to 4 otherwise). Create a single member function print() that print legs to cout.

Then create a derived Dog class with Animal as the base class that has a single private member called tail . Create a default consturctor (that sets tail to 1 calls the base constructor appropriately), and a constructor with parameters (that passes legs to the base class and sets tail to be between 0 and 1, and defaults to 1 otherwise). Create a single member function print() that prints the number of legs and tails to cout.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!