要求在三处//位置填写代码,使得输出结果为:
Cat Age:5
Cat Age:3
代码如下
#include <iostream>
using namespace std;
class CAT
{ public:
CAT();
CAT(const CAT&);
~CAT();
int GetAge() const { return *itsAge; }
void SetAge(int age){ *itsAge=age; }
protected:
int* itsAge;
};
CAT::CAT()
{
//
}
//
CAT::~CAT()
{
//
}
int main()
{
CAT mycat;
cout<<"Cat age:"<<mycat.GetAge()<<endl;
mycat.SetAge(3);
cout<<"Cat age:"<<mycat.GetAge()<<endl;
return 0;
}