某单位的职工工资包括基本工资Wage,岗位津贴Subsidy,房租Rent,水费WaterFee,电费ElecFee。设计实验工资单位管理的类Salary

#include
#include
class Salary{


private:
 double Wage;  
 double Subsidy;  
 double Rent;   
 double Waterfee;  
 double Elecfee;  


public:
   Salary(double wage=0,double subsidy=0,double rent=0,double waterfee=0,double electfee=0)
 {              
  Wage = wage;      //初始化工资数据的各分项
  Subsidy = subsidy;
  Rent = rent;
  Waterfee = waterfee;
  Elecfee = electfee;
 }
  double getWage(double f)
   {  return Wage;};
  double getSubsidy(double f)
   {return Subsidy;};
  double getRent(double f)
   {return Rent;};
  double getWaterfee(double f)
   {return Waterfee;};
  double getElecfee(double f)
   {return Elecfee;};


 double RealSalary();
 void Display();
 ~Salary(){}  //析构函数
};


double Salary::RealSalary()
{
 double realsalary=0;  //实际发放工资
 realsalary = Wage+Subsidy-Rent-Waterfee-Elecfee;
 return realsalary;
};


void Salary::Display()

 cout<<"\n                       ******** 员工工资显示 *********\n";
 cout<<"                       *     基本工资:"   <<"   "<  cout<<"                       *     岗 位 巾:"   <<"   "<  cout<<"                       *     房    租:"   <<"   "<  cout<<"                       *     水    费:"   <<"   "<  cout<<"                       *     电    费:"   <<"   "<  cout<<"                       *  ___________________________\n";
 cout<<"                       *     合 计:"      <<"      "<  cout<<"                       *******************************\n";
 cout< }


void main()
{
 Salary worker(2000,40,300,40,50);
 worker.Display();

你可能感兴趣的:(c++,初学者,class)