一段搞不定的c++代码

来源:百度知道 编辑:UC知道 时间:2024/05/21 14:21:40
我写了一段代码,编译能通过但无法运行请专家指点一下,谢谢
#include<iostream>
#include<cstring>
using namespace std;
class student
{public:
student(int n,char name[],int sc)
{num=n;
strcpy(name,name);
score=sc;
}
char *getname()
{return name;}
int getnum()
{return num;}
int getscore()
{return score;
}
static void display()
{cout<<s<<' '<<na<<' '<<temp<<endl;
}
static void max(student&);
private:
int num;
char name[20];
int score;
static int temp;
static char na[20];
static int s;

};
int student::temp=-1;
char student::na[20]=" ";
int student::s=0;
void student::max(student&stud)
{if(temp==-1)temp=stud.getscore();
if(temp<stud.getscore())
{temp=stud.getscore();
strcpy(na,stud.getname());
s=stud.getnum();
}
}
void main()<

class student
{public:
student(int n,char name[],int sc)
{num=n;
strcpy(this->name,name);//这里修改**********
score=sc;
}
char *getname()
{return name;}
int getnum()
{return num;}
int getscore()
{return score;
}
static void display()
{cout<<s<<' '<<na<<' '<<temp<<endl;
}
static void max(student&);//
private:
int num;
char name[20];
int score;
static int temp;
static char na[20];
static int s;

};
int student::temp=-1;
char student::na[20]=" ";
int student::s=0;
void student::max(student&stud)
{if(temp==-1)temp=stud.getscore();
if(temp<stud.getscore())
{temp=stud.getscore();
strcpy(na,stud.getname());
s=stud.getnum();
}
}
void main()
{student stud[3]={student(1,"k",90),student(2,"m",95),student(3,"u"