Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Jump to level 1 In the class definition, initialize the data members, string name, string color, and string type, with the default values Incomplete, Unknown,
Jump to level
In the class definition, initialize the data members, string name, string color, and string type, with the default values "Incomplete",
"Unknown", and "Unstated", respectively.
Ex: If the input is Dan camel pig, then the output is:
Name: Incomplete, Color: Unknown, Type: Unstated
Name: Dan, Color: camel, Type: pig
Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters.
Here the code:
#include
#include
using namespace std;
class Animal
public:
void SetNamestring animalName;
void SetColorstring animalColor;
void SetTypestring animalType;
void Print;
private:
Your code goes here
;
void Animal::SetNamestring animalName
name animalName;
void Animal::SetColorstring animalColor
color animalColor;
void Animal::SetTypestring animalType
type animalType;
void Animal::Print
cout "Name: name Color: color Type: type endl;
int main
string newName;
string newColor;
string newType;
Animal favoriteAnimal;
favoriteAnimal.Print;
cin newName;
cin newColor;
cin newType;
favoriteAnimal.SetNamenewName;
favoriteAnimal.SetColornewColor;
favoriteAnimal.SetTypenewType;
favoriteAnimal.Print;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started