大神求助,下面程序错在哪里呀
#include<iostream>using namespace std;
#include<string>
class Student
{
private:
int number;
string xingming;
float score;
public:
friend Lesson;
Student(int n,string x,float s ):number(n),xingming(x),score(s){}
void display()
{
cout<<xingming<<endl;
cout<<number<<endl;
cout<<score<<endl;
}
};
class Lesson
{
private:
int id, s;
string name,teacher;
public:
Lesson(int i,string n,string t,int sd):id(i),name(n),teacher(t),s(sd){}
void AddStudent(int i);
float GetPassRate(int s);
void ShowInfo();
};
void Lesson::AddStudent(int i)
{
Student stud[3]={
Student(1002,"wangfang",98),
Student(1003,"lingping",72),
Student(1004,"zhangmin",59.3f)};
stud[i].display();
}
float Lesson::GetPassRate(int s)
{
int n=0;
Student stud[3]={
Student(1002,"wangfang",98),
Student(1003,"lingping",72),
Student(1004,"zhangmin",59)};
for(int m=0;m<3;m++)
if(stud[m].score>=60.0)
n++;
return(n/s);
}
void Lesson::ShowInfo()
{
cout<<id<<endl;
cout<<name<<endl;
cout<<teacher<<endl;
cout<<s<<endl;
}
void main()
{
Lesson less(1,"c++","chen",3);
int i;
for(i=0;i<3;i++)
Lesson::AddStudent(i);
Lesson::GetPassRate(3);
less.ShowInfo();
}