Question: write a class for bunny including a private name variable. Using the constructor to initialize the name. Define a public print() method to output the

write a class for bunny including a private name variable. Using the constructor to initialize the name. Define a public print() method to output the name variable in format "Bunny name: ***". (*** is the value of name member variable).

Write the main program to first include and declare a vector of element type of pointer of bunny class object.

Then, in the first loop, use new to allocate and create 3 bunny objects (so loop for three times), taking user input for the name and using the contructor to intialize each time of the loop. Push the pointers (NOT the objects themselves) from allocation into the vector.

In the second loop, call print() through each bunny's pointer in the vector.

In the third loop, delete the bunny objects by the pointers in the vectors.

Code guidelines:

  • Good style:Use proper indentation,no magic numbers,good naming conventions.
  • Usability:Always prompt the user for input so they know what to do and provide meaningful output messages.
  • Input Validation:The program should not accept invalid input, prompt the user to reenter an input that is invalid.
  • Documentation:Add a comments that document what each part of your code does, at a minimum each function should be clearly documented by describing the expected argument values and what the function returns.
  • Testing:Make sure your code compiles and works

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!