小弟是初学者,今天写了一小段程序,但是运行时出错,望大侠们加以指点!谢了!
编译完全能通过,一点问题都没有,但是运行后只输入了一个对象的内容,回车换行后就出错不能再运行了,请个位帮忙看看,在线等,谢谢。
#include<iostream.h>
class Student
{
public:
Student(){StudentNum++;}
void Input();
void Show();
static void GetNum(){cout<<"there are "<<StudentNum<<"sudents"<<endl;}
private:
char *ID;
char *sex;
float math;
float english;
float chinese;
static int StudentNum;
};
void Student::Input()
{
cout<<"Pleses Enter the message:"<<endl;
cin>>*ID>>*sex>>math>>english>>chinese;
}
void Student::Show()
{
cout<<*ID<<*sex<<math<<english<<chinese<<endl;
}
int Student::StudentNum=0;
void main()
{
Student Ary[5];
for(int i=0;i<5;i++)
Ary[i].Input();
cout<<"学号 性别 数学 英语 语文:"<<endl;
for(int j=0;j<5;j++)
Ary[i].Show();
Student::GetNum();
}