C++ help. In the class definition, initialize the data members, string type and integer age, with the default values "Unstated" and 0, respectively. Ex: If the input is mouse 13, then the output is: Type: Unstated, Age: 0 Type: mouse, Age: 13 Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters.''' #include <iostream>#include <string>using namespace std; class Animal {   public:      void SetType(string animalType);        void SetAge(int animalAge);      void Print();    private:       /* Your code goes here */ }; void Animal::SetType(string animalType) {    type = animalType;} void Animal::SetAge(int animalAge) {    age = animalAge;} void Animal::Print() {   cout << "Type: " << type << ", Age: " << age << endl;} int main() {   string newType;    int newAge;   Animal myAnimal;    myAnimal.Print();    cin >> newType;    cin >> newAge;    myAnimal.SetType(newType);    myAnimal.SetAge(newAge);    myAnimal.Print();    return 0;}'''

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 6RQ
icon
Related questions
Question

C++ help.

In the class definition, initialize the data members, string type and integer age, with the default values "Unstated" and 0, respectively.

Ex: If the input is mouse 13, then the output is:

Type: Unstated, Age: 0 Type: mouse, Age: 13

Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters.

'''

#include <iostream>
#include <string>
using namespace std;

class Animal {
   public:
      void SetType(string animalType);
        void SetAge(int animalAge);
      void Print();

   private:

      /* Your code goes here */

};

void Animal::SetType(string animalType) {
    type = animalType;
}

void Animal::SetAge(int animalAge) {
    age = animalAge;
}

void Animal::Print() {
   cout << "Type: " << type << ", Age: " << age << endl;
}

int main() {
   string newType;
    int newAge;
   Animal myAnimal;

   myAnimal.Print();

   cin >> newType;
    cin >> newAge;

   myAnimal.SetType(newType);
    myAnimal.SetAge(newAge);

   myAnimal.Print();

   return 0;
}
'''

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Introduction to Template
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,