主题:c++题
1.
设计一个职员类EMPLOYEE,主要包括工号、姓名、部门、年龄、工资等属性以及更换部门、年龄变更、工资增长等操作,为EMPLOYEE类提供输入/输出运算“<<”和“>>”。(提示:类EMPLOYEE应有多个重载的构造函数)
题目说明:
1)类EMPLOYEE的定义可以参考如下:
class EMPLOYEE{
private:
long id;
char name[MAX_LEN];
char department[MAX_LEN];
int age;
double salary;
public:
EMPLOYEE();
EMPLOYEE(const EMPLOYEE& obj);
EMPLOYEE(long idd, char namee[], char depar[], int agee, double sala);
~EMPLOYEE();
void changeDepartment(char newDepar[]);
void changeAge(int agee);
void raiseSalary(double delta);
// 定义友元函数,提供输入/输出运算"<<"和">>"。
friend ostream& operator<<(ostream& stream, EMPLOYEE& obj);
friend istream& operator>>(istream& stream, EMPLOYEE& obj);
};
2)主函数如下所示:
void main()
{
EMPLOYEE A(200701, "Tom", "DEPARTMENT A",34,2345.6);
cout<<A;
EMPLOYEE B;
cin>>B;
cout<<"输入的信息:"<<B<<endl;
}
设计一个职员类EMPLOYEE,主要包括工号、姓名、部门、年龄、工资等属性以及更换部门、年龄变更、工资增长等操作,为EMPLOYEE类提供输入/输出运算“<<”和“>>”。(提示:类EMPLOYEE应有多个重载的构造函数)
题目说明:
1)类EMPLOYEE的定义可以参考如下:
class EMPLOYEE{
private:
long id;
char name[MAX_LEN];
char department[MAX_LEN];
int age;
double salary;
public:
EMPLOYEE();
EMPLOYEE(const EMPLOYEE& obj);
EMPLOYEE(long idd, char namee[], char depar[], int agee, double sala);
~EMPLOYEE();
void changeDepartment(char newDepar[]);
void changeAge(int agee);
void raiseSalary(double delta);
// 定义友元函数,提供输入/输出运算"<<"和">>"。
friend ostream& operator<<(ostream& stream, EMPLOYEE& obj);
friend istream& operator>>(istream& stream, EMPLOYEE& obj);
};
2)主函数如下所示:
void main()
{
EMPLOYEE A(200701, "Tom", "DEPARTMENT A",34,2345.6);
cout<<A;
EMPLOYEE B;
cin>>B;
cout<<"输入的信息:"<<B<<endl;
}