#include <iostream.h>
class TJ
{
public:
void fun_sum(int quantity,float price){
if(quantity>=10)
{
sum+=price*discount*quantity;
}
else
{
sum+=price*quantity;
}
n+=quantity;
}
void fun_average(int quantity,float price)
{
average=sum/n;
}
void display(){ //输出结果
cout<<"sum="<<sum<<"\n";
cout<<"average="<<average<<"\n";
}
private:
static float sum,average; //总销售款,平均售价
static int n; //销货件数,
int num; //销货员号
float price,discount; //销货单价,折扣,某销售员一总和
};
float TJ::sum; //静态成员需要外部声明 //这三个一定要在外面声明,否则会出错,如标题
float TJ::average;
int TJ::n;
void main()
{
TJ t1,t2,t3;
t1.fun_sum(5,23.5);
t2.fun_sum(12,24.5);
t3.fun_sum(100,21.5);
t3.display();
}