Question: 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
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
