要求:
1,查询的结果为姓名,性别,五门课的总成绩.
2,名字,学号,性别及五门课成绩定义为学生类的私有成员.
(要求在Visual C++上编译,运行)
继续提问:
1.本题是要通过输入学号查询出其他全部信息,学号是不是要弄个指针???我不会啊!教下我嘛?
2.查询的是总成绩,那就要把全部的5科成绩全部相加,用以下方法是否可行???
#include <iostream>
using namespace std;
class student
{public:
int sum();
private:
void display();
};
class student::display()
{
int a,b,c,d,e;
}
int sutdent::sum()
{
return(a+b+c+d+e);
}
int main()
{student a[8]={
student(87,65,75,72,90),
student(45,65,85,75,65),
student(60,70,80,90,100),
student(66,85,33,78,54),
student(87,67,57,47,97),
student(78,54,65,85,45),
student(88,77,66,55,44),
student(87,56,45,23,12),}
cout<<a[0].sum()<<endl;
cout<<a[1].sum()<<endl;
cout<<a[2].sum()<<endl;
cout<<a[3].sum()<<endl;
cout<<a[4].sum()<<endl;
cout<<a[5].sum()<<endl;
cout<<a[6].sum()<<endl;
cout<<a[7].sum()<<endl;
}
3.他要求名字等信息定义为private.那是不是要建立一个成员函数,如void display()
谢谢各位高手!!!