学生成绩NA
发布时间: 2020-11-29 19:04:11
A. 设计一个学生类studnet要求
#include <string>
#include <assert.h>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
class student {
int no;
string name;
float grade;
static float sum;
static int num;
public:
student(int n,string na,float d): no(n), name(na), grade(d)
{
assert(d>0);
sum += d;
num++;
}
float average()
{
return sum / num;
}
void display(int n)
{
cout << no << "\t" << name << "\t" << grade << endl;
}
};
static float student::sum = 0.0;
static float student::num = 0;
class somestudent {
void main();
// 写到这里发现你用的好像是java或者是C#。偶用的写的是C++程序。
// 挣分不容易啊,楼主,这个是一个很基础的题,如果你是计算机的学生的话,
// 还是自己看下课本吧。
// 珍惜大学时光啊。
};
PS:楼上,楼主说了sum和num是static成员你弄错了……
热点内容