78.6k views
0 votes
What methods would you add to make this class declarationvery useful?

Class Cat

{

int GetAge() const;

private:

int itsAge;

};

User Jridyard
by
6.8k points

2 Answers

4 votes

Category(int age)- This method is used to declaring the age.

incrementingAge(int age)-This method is used for incrementing the age.

SettingAge(int age) -This method is used to initializing the age.

These are the three methods for making declaration very useful.

Step-by-step explanation:

Class Cat

{

public:

Category(int age)

{

itsAge =age;

}

int incrementingAge(int age)

{

itsAge = itsAge+ age;

}

int SettingAge(int age)

{

itsAge =age;

}

int GetAge() const;

private:

int itsAge;

};Answer:

User Sneeky
by
7.0k points
6 votes

Answer:

void SetAge(int age) , void meow()

Step-by-step explanation:

Since the class has an itsAge variable as private and has a GetAge() method. There should be a SetAge() method to set the value of the age.

Also, since it is a Cat class, it is better to have a method that mimics the voice of the cat, meow()

User Norrs
by
6.1k points