c++程序设计实验辅导及习题解答-实验11(18 页)Good is good, but better carries it.精益求精,善益求善。实 验 十 一任务 1:程序调试。类静态数据的应用。下列程序设计了一个职工类,职工类中包括职工姓名、薪水和所有职工的薪水总和allSalary。薪水总和员是所有职工对象薪水的统计和,它属于类而不属于某个对象,因而设置为 static 数据。 程序为:#include "stdafx.h"#include using namespace std;#include class Employee{ private: char name[30]; float salary; static float allSalary; public: Employee(char *n, float s){ strcpy(name, n); salary = s; allSalary = allSalary + salary;}~Employee(void){}static float GetAllSalary(void) { return allSalary; } };float Employee::allSalary = 0;void main(void){Employee e1("张三", 4500);Employee e2("王五", 5200);Employee e3("李四", 2450);float all;all = Employee::GetAllSalary( ); cout << "AllSalary = " << all << endl;}任务 2:程序设计。应用类静态数据实现类名对象间的数据访问。参照任务 1,定义一个类,描述某人的姓名和具有的现金数量,此某人有 4 个子女A、B、C、D,当初父亲具有现金 10000 元,每年提供给这 4 个子女的钱分别为1000、500、2000、1800 元。当四个子女访问一次后,父亲还剩多少现金?设计代码运行如下:#include "stdafx.h"#include using namespace std;#include class people{ private: char name[30]; float salary; static float allSalary; public: people(char *n, float s){ strcpy(name, n); salary = s; allSalary = allSalary - salary;}~people(void){}static float GetAllSalary(void) { return allSalary; } };float people::allSalary = 10000;void main(void){ people e1("A", 1000);people e2("B", 500);people e3("C", 2000); people e4("D", 1800);float all;all = people::GetAllSalary( ); cout <<"访问一次后还剩现金为:" << all << endl;}任务 3:程序调试。用友元函数计算两点间的距离。#include "stdafx.h"#include using namespace std;#include class Point{public : Point(double xx ...