Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the code by c++ and use pointers as well * design an Animal class, the class name is Animal Here are the requirements: In

Write the code by c++ and use pointers as well

* design an Animal class, the class name is Animal

Here are the requirements:

In this class, it has 2 private variables.

o myVoice

o animalName

In this class, it has 3 public functions

o The 1st one is the constructor

This is how it looks like: Animal(string, string);

Since the Animal constructor takes in 2 parameters, you will need to implement that independently. In other words, the implementation is outside of the Animal class scope

So you will need the scope resolution operator, the double colon ::, when your implementation is outside of the class.

Animal::Animal(string passedInName, string passedInVoice)

The content of the constructor is your job. Hint: To deal with the 2 parameters

o The 2nd one is the function for Animals to make some noise

void animalVoice();

When you pass the parameter into the constructor, the 2nd parameter, passedInVoice decides its voice

o The 3rd one is the function to get Animals name. i.e. dog, cat, bird

string getAnimalName();

Now, in the main() function, I can do this to test all the animals by different parameters. Similarly, I can test dogs, birds, frogs,.

o For example, if I type this: Animal animal1("cat", "meow~meow~"); cout << "Hello! I am a : " << animal1.getAnimalName() << endl; animal1.animalVoice(); This will print out onto your screen: Hello! I am a : cat meow~meow~

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions