### 题目描述

#include <iostream>
#include <string>
using namespace std;
class Volunteer
{
private:
string name;      //志愿者姓名
int number;       //志愿者收集捐款的笔数
int balance;      //志愿者收集到的捐款金额
static int count; //静态成员，记录总的捐款笔数
static int sum;   //静态成员，记录总的捐款金额
public:
Volunteer(string,int,int);  //构造函数
static int get_count();     //静态成员函数，获取count的值
static int get_sum();       //静态成员函数，获取sum的值
};

//将程序需要的成份写下来，只提交begin到end部分的代码
//******************** begin ********************
________(1)_______;
int Volunteer::sum=0;
________(2)___________
{
name=nam;
number=num;
balance=bal;
count+=num;
______(3)_______;
}
int Volunteer::get_count()
{
______(4)_______;
}
int Volunteer::get_sum()
{
______(5)______;
}
//********************* end ********************
int  main( )
{
string name;
int num;
int balance;
int n;
cin>>n;  //输入志愿者人数
while(n–)
{
cin>>name>>num>>balance;
new Volunteer(name,num,balance);
}
cout<<"count: "<<Volunteer::get_count()<<endl;
cout<<"sum: "<<Volunteer::get_sum()<<endl;
return 0;
}

4
zhao 21 98
qian 18 60
sun 22 87
li 17 67

count: 78
sum: 312

### 代码如下

``````
#include <iostream>
#include <string>
using namespace std;
class Volunteer
{
private:
string name;  //志愿者姓名
int number;      //志愿者收集捐款的笔数
int balance;    //志愿者收集到的捐款金额
static int count; //静态成员，记录总的捐款笔数
static int sum;  //静态成员，记录总的捐款金额
public:
Volunteer(string,int,int);  //构造函数
static int get_count();  //静态成员函数，获取count的值
static int get_sum();   //静态成员函数，获取sum的值
};int Volunteer::count=0;
int Volunteer::sum=0;
Volunteer::Volunteer(string nam,int num,int bal)
{
name=nam;
number=num;
balance=bal;
count+=num;
sum+=bal;
}
int Volunteer::get_count()
{
return count;
}
int Volunteer::get_sum()
{
return sum;
}
int  main( )
{
string name;
int num;
int balance;
int n;
cin>>n;  //输入志愿者人数
while(n--)
{
cin>>name>>num>>balance;
new Volunteer(name,num,balance);
}
cout<<"count: "<<Volunteer::get_count()<<endl;
cout<<"sum: "<<Volunteer::get_sum()<<endl;
return 0;
}``````