Answered step by step
Verified Expert Solution
Link Copied!

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 1
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 SetName(string animalName);
void SetColor(string animalColor);
void SetType(string animalType);
void Print();
private:
/* Your code goes here */
};
void Animal::SetName(string animalName){
name = animalName;
}
void Animal::SetColor(string animalColor){
color = animalColor;
}
void Animal::SetType(string 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.SetName(newName);
favoriteAnimal.SetColor(newColor);
favoriteAnimal.SetType(newType);
favoriteAnimal.Print();
return 0;
}
image text in transcribed

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

Domain Transfer Learning With 3q Data Processing

Authors: Ahmed Atif Hussain

1st Edition

B0CQS1NSHF, 979-8869061805

More Books

Students also viewed these Databases questions

Question

2. Outline the functions of nonverbal communication

Answered: 1 week ago