Question: Create a class that can work with the following main. You may need to add any missing libray to get it to work. int main()

Create a class that can work with the following main.

You may need to add any missing libray to get it to work.

int main()

{

string name,

int age

Pet A; // default constructor

cout << "What is the Pet name and age: ";

cin >> name >> age;

A.setName(name); // set Pet's name

A.setAge(age); // set Pet's age

cout << A; // overload the stream insertion operator (operator <<)

Pet B("Max", 5); // custom constructor

cout << B; // overload the stream insertion operator (operator <<)

Pet C("Lady") // custom constructor

cout << "My pet name is " << c.getName() << " and the pet age is " c.getAge() << endl;

// Should print : My pet name is Lady and the pet age is 0; (Hint: 0 is a default value)

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!