Question: Could someone please help me with my C++ project. Please include all steps into one cpp files. The text below is the starting template code.
Lab 3 For this lab you'll work with pointers and polymorphism. Step 1 Download the starter file animal.cpp and add it to a Visual Studio project. You will do all your work in this file. Step 2 In the starter file you're given a simple Animal class. The Animal has a name, a constructor which sets its name, and a speak) method which prints the noise the Animal makes and what sort of animal it is Find the I/STEP 2 comment and insert a Dog class that inherits from Animal (for all following steps insert the code at the appropriate comment). The Dog class should have its own constructor which sets its name and its own speak() method which displays "Woof! says name where name is replaced with the Animals name. Step 3 Insert a Cat class that inherits from Animal This will be identical to the Dog class, but its speakl) method will say "Meow! Says name Step 4 Write a void function called giveShot() that accepts a pointer to an Animal object as a parameter. getShot() displays "I'm giving the animal a shot.... then calls the Animal's speak) method Step 5 Create a Dog and Cat object on the free space using new. Using the constructor give the Dog and Cat names of your choosing. You'll need to save the address for each object into a pointer Step 6 Call giveshot) on your Dog object and Cat object created in step 5. Step 7 At this point you should be able to run your program. Try it out
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
