请教大家啊,我怎么编的这个程序出错了啊,
谁来帮帮我,谢谢了//头文件
#include <iostream>
#include <string>
using namespace std;
class student
{
public:
student();
int count();
void show();
private:
string num;
string name;
int g1;
int g2;
int all;
};
//实现的过程
#include "lei.h"
student::student()
{
cout<<"enter the name of the stu"<<endl;
cin>>name;
cout<<"enter the grade"<<endl;
cin>>g1>>g2;
}
int student::count()
{
all = g1 + g2;
return all;
}
void student::show()
{
cout<<name<<endl;
}
//主函数
#include "lei.h"
void main(void)
{
student s1;
student s2;
student s3;
int k;
student p[3] = {s1,s2,s3};
for (int i = 0;i < 1;i++)
{
for (int j = 0; j< 2;j++)
{
if(p[i].count() < p[i+1].count())
{
k = p[i].count ();
p[i].count () = p[i+1].count ();
p[i+1].count ()= k;
}
}
p[i].show();
}
}