c程序设计实验辅导及习题解答-实验.docxVIP

  • 9
  • 0
  • 约3.57千字
  • 约 11页
  • 2022-08-01 发布于山东
  • 举报

c程序设计实验辅导及习题解答-实验.docx

实验十一 任务1:程序调试。类静态数据的应用。 下列程序设计了一个员工类,员工类中包括员工姓名、薪资和所有员工的薪资总和allSalary。薪资总和员是所有员工对象薪资的统计和,它属于类而不属于某个对象,因而设置为static数据。 程序为: #include #includeiostream usingnamespacestd; #include classEmployee { private: charname[30]; floatsalary; staticfloatallSalary; public: Employee(char*n,floats) { strcpy(name,n); salary=s; allSalary=allSalary+salary; } ~Employee(void){} staticfloatGetAllSalary(void) {returnallSalary;} }; floatEmployee::allSalary=0; voidmain(void) { Employeee1(张三,4500); Employeee2(王五,5200); Employeee3(李四,2450); floatall; all=Employee::GetAllSalary( ); coutAllSalary=allendl; } 任务2:程序设计。应用类静态数

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档