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

  • 13
  • 0
  • 约4.16千字
  • 约 7页
  • 2020-07-18 发布于江苏
  • 举报

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

实验十一 任务 1:程序调试。类静态数据的应用。 下列程序设计了一个职工类, 职工类中包括职工姓名、 薪水和所有 职工的薪水总和 allSalary 。薪水总和员是所有职工对象薪水的统计 和,它属于类而不属于某个对象,因而设置为 static 数据。 程序为: #include stdafx.h #include iostream usingnamespace std; #include string.h class Employee { private : char name[30]; float salary; staticfloat allSalary; public : Employee( char *n, float s) { strcpy(name, n); salary = s; allSalary = allSalary + salary; } ~Employee(void ){} staticfloat GetAllSalary( void ) { return allSalary; } }; float  Employee::allSalary = 0; void main( void ) { Employee e1( 张三 , 4500); Employee e2( 王五 , 5200); Employee e3( 李四 , 2450);

文档评论(0)

1亿VIP精品文档

相关文档