高手帮我改一下这个c++程序

来源:百度知道 编辑:UC知道 时间:2024/06/07 14:14:25
#include<iostream>
using namespace std;
class CStudent {
int XH;
char XM[25];
float SX;
float WY;
float JSJ;
public:
CStudent();
float sum(float,float,float);
float averge(float,float,float);
void display();
void setdata();};
CStudent::CStudent(){XH=0;XM[0]='\0';SX=0.0;WY=0.0;JSJ=0.0;} //构造函数
float CStudent::sum(float SX,float WY,float JSJ){
return(SX+WY+JSJ);
}
float CStudent::averge(float SX,float WY,float JSJ){
return((SX+WY+JSJ)/3);
}
void CStudent::display(){
cout<<"学号"<<XH<<endl;
cout<<"姓名"<<cin.getline(XM,25)<<endl;
cout<<"数学成绩"<<SX<<endl;
cout<<"外语成绩"<<WY<<endl;
cout<<"计算机成绩"<<JSJ<<endl;
cout<<"总成绩"<<sum(SX,WY,JSJ)<<endl;

==========================================
//我在保留了你的函数名的基础上,进行了修改。只记下了我记得的地方。
//已经在VC6.0测试OK。如果有问题,可再找我。
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>//加了string风格字符串。
#define m 2 //把你的200改成了2,方便测试。
using namespace std;

class CStudent
{
private:
int XH;
string XM; //修改处。
float SX;
float WY;
float JSJ;
public:
CStudent();
float sum(float SX,float WY,float JSJ);
float average(); //修改处。
void display();
void setdata(int xh,string& xm,float sx,float wy,float jsj); //修改处。
};

CStudent::CStudent()/////////构造函数
{
//修改处。
}
void CStudent::setdata(int xh,string& xm,float sx,float wy,float jsj) //修改处。
{
XH=xh;
XM=xm;
SX=sx;
WY=wy;
JSJ=jsj;
}

float CStudent::sum(float SX,float WY,float JSJ)
{
int sum;