跪求一个C++源代码,谢谢~!要是合适追加赏分。。。。

来源:百度知道 编辑:UC知道 时间:2024/09/20 02:31:32
不要太短的也别太长了,能用信纸写4、5页就行。满意的追加20分。谢谢
别说让我自己写。。。我要会写就不跪求了,我这网速不行,没法下载,你们最好把程序直接复制到这里#17 谢谢啊。明天就交作业了#15我穷啊,就这点分数了,我刷的分都让百度给扣了,还封了好几星期的号。。。

#include<iostream.h>
class Animal
{
public:
Animal()
{
cout<<"Animal的构造函数被调用"<<endl;
cout<<"Animal的数据:";
age=3;
cout<<"age="<<age<<endl;
}
~Animal()
{
cout<<"Animal的析构函数被调用"<<endl;
}
int age1;
private:
int age;
};
class dog :public Animal
{
public:
dog(int x):age(x)
{
cout<<"age="<<age<<endl;
cout<<"dog的构造函数被调用"<<endl;
}
void setage()
{
age1=5;
age=6;
cout<<"age1="<<age1<<endl;
cout<<"age="<<age<<endl;
}
~dog()
{
cout<<"dog的析构函数被调用"<<endl;
}
private:
int age;
};
void main()
{
dog dog1(5);
dog1.setage();