#include "iostream"
#include "string.h"
using namespace std;
class Person{
private:
char name[30];//姓名
int age;//年龄
char identity[30];//身份证号
char position[20];//工作
double salary;//工资
public:
Person(char * lname,int lage,char *lidentity,char * lposition,double lsalary)
{
strcpy(name,lname);
age=lage;
strcpy(identity,lidentity);
strcpy(position,lposition);
salary=lsalary;
}
char *GetPersonName()
{
return name;
}
int GetPersonAge()
{
return age;
}
char *GetPersonIdentty()
{
return identity;
}
char *GetPersonPosition()
{
return position;
}
double GetPersonSalary()
{
return salary;
}
};
int main()
{
Person myPerson("LiMing",23,"544786198702212345","Professor",4000.0);
cout<<"Name:"<<myPerson.GetPersonName()<<endl;
cout<<"Age:"<<myPerson.GetPersonAge()<<endl;
cout<<"Identity:"<<myPerson.GetPersonIdentty()<<endl;
cout<<"Position:"<<myPerson.GetPersonPosition()<<endl;
cout<<"Salary:"<<myPerson.GetPersonSalary()<<endl;
return 0;}
运行结果: