帮忙C++啊,,现在等着急用,,高手就简单,我是初学者

来源:百度知道 编辑:UC知道 时间:2024/06/24 08:31:59
设计一个雇员(Employee)类,有数据成员姓名(Name)和薪水(Pay);成员函数SetName ()、SetPay()和Print()等,其中Print()用来输出雇员信息。要求:
①构造函数(重载);
②形参有缺省值、有内联函数;
③定义main()函数,测试雇员类。

#include<iostream>
#include<string>
using namespace std;

class Employee
{
public:
string name;
int pay;

Employee();
Employee(string,int );
string SetName(string);
int SetPay(int );
inline int print();
};
Employee::Employee()
{
}
Employee::Employee(string name_i="some_one",int pay_i=5000)
{
name = name_i;
pay = pay_i;
}
string Employee::SetName(string name_i="someone")
{
name = name_i;
return name;
}
int Employee::SetPay(int pay_i = 5000)
{
pay = pay_i;
return pay;
}
int Employee::print()
{
cout<<"职员名字:"<<name<<endl;
cout<<"职员薪水:"<<pay<<endl;
return 1;
}
int main()
{
Employee a("jone",1000);
Employee b("kerry");//缺省pay
a.print();
b.pri