展开全部
#include <iostream>
using namespace std;
class Animal{
protected:
int age;
};
class dog:public Animal{
public:
void SetAge(int n)
{
age = n;
}
int GetAge()
{
return age;
}
};
int main()
{
dog d;
d.SetAge(1);
cout << d.GetAge() << endl;
return 0;
}
复制过来后格式没了,自己搞一下吧
using namespace std;
class Animal{
protected:
int age;
};
class dog:public Animal{
public:
void SetAge(int n)
{
age = n;
}
int GetAge()
{
return age;
}
};
int main()
{
dog d;
d.SetAge(1);
cout << d.GetAge() << endl;
return 0;
}
复制过来后格式没了,自己搞一下吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询