#include <iostream>
#include <cstring>
using namespace std;
class Employee {
private :
char name[ 50 ] ;
char city[ 50 ] ;
char address[ 100 ] ;
char postcode[ 10 ] ;
public :
// 构造函数
Employee( const char * initName, const char * initCity, const char * initAddress, const char * initPostcode) {
strcpy ( name, initName) ;
strcpy ( city, initCity) ;
strcpy ( address, initAddress) ;
strcpy ( postcode, initPostcode) ;
}
// change_name函数
void change_name( const char * newName) {
strcpy ( name, newName) ;
}
// display函数
void display( ) const {
cout << "Name: " << name << endl;
cout << "City: " << city << endl;
cout << "Address: " << address << endl;
cout << "Postcode: " << postcode << endl;
}
} ;
int main( ) {
// 输入
char name[ 50 ] , city[ 50 ] , address[ 100 ] , postcode[ 10 ] , newName[ 50 ] ;
cin .getline ( name, 50 ) ;
cin .getline ( city, 50 ) ;
cin .getline ( address, 100 ) ;
cin .getline ( postcode, 10 ) ;
cin .getline ( newName, 50 ) ;
// 创建Employee对象实例
Employee emp( name, city, address, postcode) ;
// 第一次调用display函数输出属性信息
emp.display ( ) ;
// 调用change_name函数改变姓名
emp.change_name ( newName) ;
// 再次调用display函数输出属性信息
emp.display ( ) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBFbXBsb3llZSB7CnByaXZhdGU6CiAgICBjaGFyIG5hbWVbNTBdOwogICAgY2hhciBjaXR5WzUwXTsKICAgIGNoYXIgYWRkcmVzc1sxMDBdOwogICAgY2hhciBwb3N0Y29kZVsxMF07CgpwdWJsaWM6CiAgICAvLyDmnoTpgKDlh73mlbAKICAgIEVtcGxveWVlKGNvbnN0IGNoYXIqIGluaXROYW1lLCBjb25zdCBjaGFyKiBpbml0Q2l0eSwgY29uc3QgY2hhciogaW5pdEFkZHJlc3MsIGNvbnN0IGNoYXIqIGluaXRQb3N0Y29kZSkgewogICAgICAgIHN0cmNweShuYW1lLCBpbml0TmFtZSk7CiAgICAgICAg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