这是一个类问题
#include
#include
class country
{
private:
char Name[20];
float Num,Area;
public:
country(char *name,float num,float area);
country( country&C);
~country(){};
void setcountry(char *name,float num,float area);
void Getcountry();
};
country::country(char *name,float num,float area)
{
strcpy(Name,name);
Num=num,Area=area;
}
country::country(country &c)
{
strcpy(Name,c.Name);
Num=c.Num,Area=c.Area;
}
void country::setcountry(char*name,float num,float area)
{strcpy(Name,name);
Num=num,Area=Area;
}
void country::Getcountry()
{
cout<<"名称:"<
}
void main()
{
country A("美国佬",100,50);
A.Getcountry();country E(A);E.Getcountry();
E.setcountry("美国 ",1000,500);
E.Getcountry();
}
为什么最后输出的结果中重复了“名称:美国佬人口100面积:50”
谢谢!!!
--------------------next---------------------
阅读(1097) | 评论(0) | 转发(0) |