Answered You can hire a professional tutor to get the answer.

QUESTION

Define a Pet class that stores the pet's name as a C++ string and weight as protected members. Add appropriate constructors, accessor functions, and...

Define a Pet class that stores the pet's name as a C++ string and weight as protected members.

Add appropriate constructors, accessor functions, and mutator functions. Also define a function

named getLifespan that returns a string with the value "unknown lifespan."

string getLifespan();

Next, define a Dog class that is derived from Pet. The Dog class should have a private

member variable named breed that stores the breed of the dog as a C++ string. Add appropriate

constructors, mutator functions, and accessor functions for the breed variable. Redefine the

getLifespan function to return "Approximately 7 years" if the dog's weight is over 100 pounds

and "Approximately 13 years" if the dog's weight is under 100 pounds.

In the driver,

• need Pet object and Dog pointer.

• Ask the user for the information to set the data members for a Pet object.

• Print the lifespan of a Pet.

• Ask the user for the number of dogs.

• need dynamic array of Dog objects.

• Ask the user for the information to set the data members for each Dog object.

• Print the lifespan for all the dogs.

• Don't forget to delete your Dogs!

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question