Question: write a C + + program Task _ A Add a protected data member named id of integer type to Animal class. Task _ B
write a C program
Task A
Add a protected data member named id of integer type to Animal class.
TaskB
Add getset methods for id data member in Animal class with public access.
TaskC
Add a default constructor to each of the above created class. The constructor should initialize the id data member of Animal, Reptile, Bird and Mammal, to and respectively also it display a message class Names default constructor
TaskD
Add a parameterized constructor to each of the above created class. The constructor should initialize the id data member of Animal, Reptile, Bird and Mammal, to the specified id passed to the constructor also it display a message class Names default constructor The parameterized constructor should call its base class parameterized constructor to initialize any data member inherited from the base class.
TaskE
Add a destructor to each of the above created class. The destructor should display a
message class Names default destructor
TaskF
Add a getFamily method to Snake, Parrot and Horse classes, this method must return the id of a particular animals family where it belongs to
TaskG
Add a tellAboutSelf method to Animal class with public access. The method displays the name of each objects class where it belongs to
TaskH
Override the tellAboutSelf in all the subleaving classes of Animal with the same functionality as in Animal class.
TaskI
Add a speak method to Animal class and override it in each of the subleaving classes. The Animal, Reptile, Bird, Mammal, Snake, Parrot and Horse can speak by printing a message I am Animal, I cant speak...Family of Reptiles...Family of Birds...Family of Mammals...ShhhTrrrr and Hurrrrr respectively.
TaskJ
Write down your main method and instantiate object of each class created above, call tellAboutSelf, speak and getFamily methods for each of the created object.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
