Question: C++ Pet Inheritance Practice 2: Base Class Define a Pet class that stores the pet's name, age, and weight. . Add appropriate constructors, accessor, and

C++
 C++ Pet Inheritance Practice 2: Base Class Define a Pet class
that stores the pet's name, age, and weight. . Add appropriate constructors,
accessor, and mutator functions. . Also define a function named getLifespan that

Pet Inheritance Practice 2: Base Class Define a Pet class that stores the pet's name, age, and weight. . Add appropriate constructors, accessor, and mutator functions. . Also define a function named getLifespan that returns a string with the value "unknown lifespan." Write two files: pet.h and pet.cpp Practice 2: Derived Classes 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. Add mutator and accessor functions for the breed variable and appropriate constructors. 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. Write two files: dog.h and dog.cpp Practice 2: Derived Classes (cont.) Define a Turtle class that is derived from Pet. Redefine the getLifespan function to return "Hundreads of years". Write two files: turtle.h and turtle.cpp Practice 2: Testing Write a test program that creates instances of pet turtles and pet dogs that exercise the inherited and redefined functions ido. age 5. weight 120. breed Great Dane pproxi mately 7 years ippen, age 2, weight 45, breed Dalmatian pproximately 13 years occo, age 99, weight 1 lundreads of years Practice 2: Testing (cont.) int main) ( Dog fido("Fido", 5, 120, "Great Dane) Dog pippen("Pippen", 2, 45, "Dalmatian) Turtle rocco( "Rocco", 99, 1); ",

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!