Question: 1. Last week we had 5. Write a class that simulates an animal in a zoo. An animal has an animal_type and name (strings), age

1. Last week we had "5. Write a class that simulates an animal in a zoo. An animal has an animal_type and name (strings), age and weight (integers). Write a default constructor. Get/set functions are not (yet) needed."

Modify the Animal class using "this" and "const" keywords. Write the get/set functions for all the member variables.

2. Using "static": Add a static variable called acount in the animal class. Introduce 2 animal variables in the main function. Print the value of acount.

3. Inheritance. Write another class called Primate, that is a subtype of Animal. It inherits all the (public) functions of Animal, so you don't need to re-write them for Primate. However, Primate has an additional function void grasp(string thingy). Write this function. It should output "[Animal name] grasps [thingy]".

4. What does the following stupid code do?

const unsigned int ASIZE = 10; int intarr[ASIZE];

void stupid(int* arr, int pos) { if (pos == 0) { arr[0] = 0; return; } arr[pos] = pos; stupid(arr, pos-1); }

Note: I need all answer on C++ code

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!