大家帮我看下,没有错但运行无法输入
#include<iostream>#include<string>
using namespace std;
class Date{
public:
Date();
Date(char *name,int ID,char Sex,int Math,int English,int C,int Computer);
void showstudent();
void aver(int Average,int Math,int English,int C,int Computer);
private:
char *name;
int ID;
char Sex;
int Math;
int English;
int C;
int Computer;
int Average;
};
Date::Date(char *name,int ID,char Sex,int Math,int English,int C,int Computer)
{
name=new char[10];
cin>>name>>ID>>Sex>>Math>>English>>C>>Computer;
aver(Average,Math,English,C,Computer);
delete []name;
}
Date::Date()
{}
void Date::showstudent()
{cout<<name<<" "<<ID<<" "<<Sex<<" "<<Math<<" "<<English<<" "<<C<<" "<<Computer<<" "<<Average<<endl;}
void Date::aver(int Average,int Math,int English,int C,int Computer)
{
Average=(Math+English+C+Computer)/4;
}
int main()
{
int q;
cout<<"Please Input the Number of Students:"<<endl;
cin>>q;
cout<<"Please input"<<" "<<q<<" "<<"student info: Name ID Sex Math English C Computer"<<endl;
Date *stu=new Date[q];
cout<<endl<<"Student Information you input:"<<endl;
cout<<"Name ID Sex Math English C Computer Average"<<endl;
for(int i=0;i<4;i++)
{
stu[i].showstudent();
}
delete []stu;
return 0;
}