根据main函数的调用以及程序的输出完成类定义,实现指定的功能
代码实现:
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
/*请在这里写上相应的类定义*/
class Salesman{
private:
string name;
int num,price;
float part;
static float sum;
static int numo;
public:
Salesman(string n,int num,int pri,float par):name(n),num(num),price(pri),part(par){
numo+=1;
sum+=num*price*part;
}
static void show(){
cout<<"There are "<<numo<<" salesmen,sales amount is:"<<sum<<endl;
}
static float getAver(){
return sum/numo;
}
};
float Salesman::sum = 0;
int Salesman::numo = 0;
int main(){
Salesman sman[]={
Salesman("Li",4,100,0.5),
Salesman("Wang",3,200,0.4),
Salesman("Liu",2,300,0.3)
};
Salesman::show();
cout<<"Average commission is:"<<Salesman::getAver()<<endl;
return 0;
}