Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago