Question: C++ In the Moose class, complete the function definition for SetAge() that takes in the integer parameter newAge. Ex: If the input is beige Pat

C++

In the Moose class, complete the function definition for SetAge() that takes in the integer parameter newAge.

Ex: If the input is beige Pat 11, then the output is:

Color: beige Name: Pat Age: 11

using namespace std;

class Moose { public: void SetColor(string newColor); void SetName(string newName); void SetAge(int newAge); string GetColor() const; string GetName() const; int GetAge() const; private: string color; string name; int age; };

void Moose::SetColor(string newColor) { color = newColor; }

void Moose::SetName(string newName) { name = newName; }

/* Your code goes here */ { age = newAge; }

string Moose::GetColor() const { return color; }

string Moose::GetName() const { return name; }

int Moose::GetAge() const { return age; }

int main() { Moose moose1; string userColor; string userName; int userAge;

cin >> userColor; cin >> userName; cin >> userAge;

moose1.SetColor(userColor); moose1.SetName(userName); moose1.SetAge(userAge); cout << "Color: " << moose1.GetColor() << endl; cout << "Name: " << moose1.GetName() << endl; cout << "Age: " << moose1.GetAge() << endl;

return 0; }

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!