还是不行,以下是我写,求大家看看
//student_.h
#include <string>
using namespace std;
using std::string;
class Student
{
private:
int num;
string name;
string sex;
int scoure[5];
int total_scoure;
public:
void getin();
void serach();
void putout();
}
//student_.cpp
#include "iostream"
#include "student_.h"
#include "string"
using namespace std;
using std::string;
void STUDENT::getin(Student&s)
{
int i;
cout <<"请输入学号:";
cin >>s.num;
cout <<"请输入:";
cin >>s.name;
cout <<"请输入性别:";
cin >>s.sex;
for(i=0;i<5;i++) {cout <<"请输入第"<<i+1<<"科成绩:"cin >>s.score[i];}
cout <<endl;
for(i=0,s.total_score=0;i<5;i++) s.total_score+=s.score[i];
}
int serach(Student&s)
{
return s.num;
}
void putout(Student&s)
{
cout <<"name:"<<name<<'\t';
cout <<"sex:"<<sex<<'\t';
cout <<"total_score:"<<total_score<<endl;
}
int main()
{
Student arry[8];
int i,number;
for(i=0;i<8;i++) getin(arry[i]);
cout <<"请输入你想查的学号:";
cin >>number;
for(i=0;i<8;i++)
{
if(number==serach(arry[i])) putout(arrt[i]);
else cout <<"No the number!"<<endl;
}
return 1;
}