Question: Answer in C + + Implement a class named Animal has two private member variables: name of type string and numLegs of type int, and
Answer in C
Implement a class named Animal has two private member variables: name of type string and numLegs of type int, and has the following member functions:
setNameFunction to set the name
setNumLegsFunction to set the number of animal legs
getNameValuereturning function to return the name
getNumLegsValuereturning function to return the number of animal legs
TEXAS A&M UNIVERSITY CORPUS CHRISTI
School of Engineering & Computing Sciences
speak Valuereturning function to return the empty string
move Valuereturning function to return the empty string
print Outputs the data stored in the instance variables with the appropriate titles
Constructor with parameterSets the values of the instance variables to the values specified by the user, in default: sets name to the empty string and number of legs to
Using an Animal class as a base class, implement two derived classes simulating a cat and Dog, each redefining three functions constructor, speak move to represent each animal the most suitable.
Then write the main class that creates instances of three above classes one for each
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
