?return 0;
}
//employee.h
#include<iostream>
#include<string>
usingnamespace std;
const int MAX_LEN=100;
classEMPLOYEE{
private:
long id;
?char name[MAX_LEN];
?char department[MAX_LEN];
int age;
double salary;
public:
EMPLOYEE();
?EMPLOYEE(constEMPLOYEE&obj);
?EMPLOYEE(long idd, char namee[], chardepar[], int agee, doublesala); ?~EMPLOYEE();
?void changeDepartment(char newDepar[]);
void changeAge(intagee);
?voidraiseSalary(double delta);
?
//定义友元函数,提供输入/输出运算"<<"和">>"。
?friend ostream& operator<<(ostream& stream,EMPLOYEE& obj);
?friend istream& operator>>(istream& stream, EMPLOYEE& obj);};
EMPLOYEE::EMPLOYEE()
{
id=000000;
}
EMPLOYEE::EMPLOYEE(const EMPLOYEE& obj)//拷贝构造函数
{
?id=obj.id;
strcpy(name,obj.name);
?strcpy(department,obj.department);
age=obj.age;
salary=obj.salary;
}
EMPLOYEE::EMPLOYEE(long idd, char namee[],char depar[],int agee,double sala)
{
?id=idd;
?strcpy(name,namee);
?strcpy(department,depar);
?age=agee;
salary=sala;
}
EMPLOYEE::~EMPLOYEE()
{
}
ostream& operator<<(ostream& stream,EMPLOYEE&obj)
{
stream<<"{"<?stream<?return stream;
?
}
istream& operator>>(istream& stream,EMPLOYEE&obj)
{
?cout<<"输入工号:";
stream>>obj.id;
//接收键盘上的字符串处理起来比较麻烦。。。。