#include<stdio.h>
#include<string.h>
class Student//类定义
{
//私有成员变量定义属性
private:
int id;
char name[10];//缓冲区溢出,5个字符后面的不爱这个字符数组管理之内。
float english;
float math;
float history;
float average;
//构造函数
public:
Student(int id)//无参数的构造函数
{
this->id = id;
}
Student(int id,char name[],float english,float math,float history)
{
this->id = id;
strcpy(this->name,name);
this->english = english;
this->math = math;
this->history = history;
CalcAverage();
}
public:
//共有属性
int GetId()
{
return this->id;
}
char* GetName()
{
return this->name;
}
void SetName(char name[])
{
strcpy(this->name,name);
}
float GetAverage()
{
return average;
}
float GetEnglish()
{
return english;
}
void SetEnglish(float english)
{
this->english = english;
CalcAverage();
}
float GetMath()
{
return math;
}