Question: 4 Question 4 . You are given two classes Chicken and Egg, described below. . The class Chicken contains a vector of Eeg objects. class

 4 Question 4 . You are given two classes Chicken and

Egg, described below. . The class Chicken contains a vector of Eeg

4 Question 4 . You are given two classes Chicken and Egg, described below. . The class Chicken contains a vector of Eeg objects. class Chicken ( public: void layEgg ; int numEggs ) const; void getEggs (vector v); private: vector vec eggs: b: 1. The method numEggs returns the size of the vector vec.eggs and is const. 2. Method layEgg: instantiate an Egg object and push it back onto the vector vec.eggs. Do not use dynamic memory. Just instantiate "Egg e" and push back e onto the vector. 3. In the method getEggs, do two things: (a) Set u to a copy of the vector vec.eggs. (b) Clear the vector vec-eggs. (c) In other words, the farmer collects the eggs and the chicken has no more eggs. . The class Egg contains a method hatch which returns a pointer to a new Chicken. class Egg t private: bool born; public: Egg) f born false; bool isBorn) const ( return born; Chicken+ hatchO 1. The default constructor initializes born to false. The code is written for you. 2. The accessor method isBorn() returns the value of born. The code is written for you. 3. In the method hatch, do the following (a) If bora is true, return NULL, and exit. An egg cannot hatch more than ouce. (b) If born is false, set born true. Dynamically create a new Chicken and return a pointer to the dynamic menory In other words, a new chicken is born

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!