Question: C++ question: This lab demonstrates polymorphism. Implement a class called Animal that contains a constructor Animal(string title); an accessor for title a method void move(

C++ question:

This lab demonstrates polymorphism. Implement a class called Animal that contains a constructor Animal(string title); an accessor for title a method void move( ); that prints "I have no idea" title as private data Create at least two subclasses derived from Animal that override the move method with a specific output message like "I hop"

Include in source code the following function: void animalMovesBy(Animal *bp) { cout << bp->getName() << ", how do you move? "; bp->move(); } In main, instantiate a basic Animal and instances of your subclasses and for each of the animals make a call to animalMovesBy by passing it the address of the animal. The function should result in calling the move function specific to that animal.

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!