帮我看看这个c++题目哪里有错误啊?

[复制链接]
查看11 | 回复2 | 2011-1-14 10:49:36 | 显示全部楼层 |阅读模式
6、编写一个程序,输入3个学生的英语和计算机成绩,并按总分从高到低排序(要求设计一个学生类Student)。
程序如下:#include "stdafx.h"
#include
using namespace std;
class student
{private : float E;float C;
public:

student(float e,float c);

~student( ){ }

float getE( ){ return E;)

float getC( ){ return C;}

float total( ){ return (E+C);}
};
student::student(float e,float c)
{

E=e;

C=c;
}
void rank( float &x,float &y)
{
int i;
if(x>a>>b>>c>>d>>e>>f;

student A(a,b);

student B(c,d);

studenC(e,f);

int m,n,x;

m=A.total( );

n=B.total( );

x=C.total( );

rank(m,n);

rank(m,x);

rank(n,x);

cout<<m<<"
"<<n<<"
"<<x<<endl;

return 0;
}

总提示这种错误
C:\Program Files\Microsoft Visual Studio\MyProjects\werf\werf.cpp(18) : error C2535: '__thiscall student::student(float,float)' : member function already defined or declared
C:\Program Files\Microsoft Visual Studio\MyProjects\werf\werf.cpp(48) : fatal error C1004: unexpected end of file found

回复

使用道具 举报

千问 | 2011-1-14 10:49:36 | 显示全部楼层
student 的构造函数你定义为都是float的参数,你在声明的时候传递的是int的参数从你实现来看,没用到float相关的东西,就把student 里边的float都改成int应该就可以
回复

使用道具 举报

千问 | 2011-1-14 10:49:36 | 显示全部楼层
程序BUG修改完成,单有业务逻辑错误#pragma argsused#include using namespace std;class student{
private :
float E;
float C;
public:
student
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行