工人类有name 年龄age 工作部门dept 工资类成员salary中有基本工资wage 岗位津贴subsidy。房租rent。水费waterfee。电费elecfee。并统计工人人数

#include"iostream"
using namespace std;
class salary{
private:
double wage,subsidy,rent,waterfee,elecfee;
public:
salary(double a,double b,double c, double d,double e):wage(a),subsidy(b),rent(c),waterfee(d),elecfee(e){}
salary(){
wage=subsidy=rent=waterfee=elecfee=0;
}
void setwage(double f){ wage=f; }
void setsubsidy(double f){ subsidy=f; }
void setrent(double f){ subsidy=f; }
void setwaterfee(double f){ waterfee=f; }
void setelecfee(double f){ elecfee=f; }
double getwage(){ return wage; }
double getsubsidy(){ return subsidy; }
double getrent(){ return rent; }
double getwaterfee(){ return waterfee; }
double getelecfee(){ return elecfee; }
double realsalary();
};


double salary::realsalary(){
double realsalary;
realsalary=wage+subsidy-rent-waterfee-elecfee;
return realsalary;
}


class worker{
private:
static int m;
char name[8];
int age;
char dept[8];
salary A;
public:
worker::worker(char* a,int b,char* c,double d,double e,double f,double g,double h):age(b),A(d,e,f,g,h)
{
strcpy(name,a);
strcpy(dept,c);
m++;


};
int getm(){ return m; }
};






int worker::m=0;


void main(){
worker x1("liu",20,"suibian",1000,200,500,100,200);
worker x2("pp",21,"suibian",1000,200,500,100,200);
cout << x1.getm() << endl;
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值