#include <iostream.h>
#include <string.h>
#define N 10
class CWork //定义一个类
{
private:
char name[N],addr[N];
char city[N],province[N];
char youbian[6];
public:
CWork(char name[N], char addr[N], char city[N], char province[N],char youbian[6]);
void ChangName();
void Display();
};
CWork::CWork(char name[N], char addr[N], char city[N], char province[N],char youbian[6])
{
char a[N],b[N],c[N],d[N],s[6];
strcpy(name,a);
strcpy(addr,b);
strcpy(city,c);
strcpy(province,d);
strcpy(youbian,s);
}
void CWork::ChangName(char m)
{
strcpy(name,m);
}
void CWork::Display()
{ int i;
cout<<"输入人物信息:"<<endl;
for(i=0;i<N;i++)
cout<<"Name:"<<name[i];
cout<<endl;
for(i=0;i<N;i++)
cout<<"Address:"<<addr[i];
cout<<endl;
for(i=0;i<N;i++)
cout<<"City:"<<city[i]<<endl;
cout<<endl;
for(i=0;i<N;i++)
cout<<"Province:"<<province[i];
cout<<endl;
for(i=0;i<6;i++)
cout<<"Youbian:"<<youbian[i];
cout<<endl;
}
void main()
{
int i,j;
char xming[N],dizhi[N];
char cshi[N],sheng[N];
char ybian[6],n[N];
cout<<"请输入新名:"<<endl;
for(i=0;i<N;i++)
cin>>n[i];
cout<<"请输入姓名:"<<endl; //下面是初始化类
for(i=0;i<N;i++)
cin>>xming[i];
cout<<endl;
cout<<"请输入地址:"<<endl;
for(i=0;i<N;i++)
cin>>dizhi[i];
cout<<endl;
cout<<"请输入城市名:"<<endl;
for(i=0;i<N;i++)
cin>>cshi[i];
cout<<endl;
cout<<"请输入省份:"<<endl;
for(i=0;i<N;i++)
cin>>sheng[i];
cout<<endl;
cout<<"请输入邮编:"<<endl;
for(i=0;i<N;i++)
cin>>ybian[i];
cout<<endl;
class M(xming[N],dizhi[N],cshi[N],sheng[N],ybian[6]);
M.ChangName(n);
M.Display();
}