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.
Task_B
Add get/set methods for id data member in Animal class with public access.
Task_C
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 0,1,2 and 3 respectively also it display a message (class Name)s default constructor.
Task_D
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 Name)s default constructor. The parameterized constructor should call its base class parameterized constructor to initialize any data member inherited from the base class.
Task_E
Add a destructor to each of the above created class. The destructor should display a
message (class Name)s default destructor.
Task_F
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.
Task_G
Add a tellAboutSelf method to Animal class with public access. The method displays the name of each objects class where it belongs to.
Task_H
Override the tellAboutSelf in all the sub-leaving classes of Animal with the same functionality as in Animal class.
Task_I
Add a speak method to Animal class and override it in each of the sub-leaving 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...,Shhh....,Trrrr.... and Hurrrrr... respectively.
Task_J
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.
write a C + + program Task _ A Add a protected

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 Programming Questions!