一个简单的问题,输出那里为什么不行
#include <iostream>using namespace std;
class Student
{
private:
int age;
char *name;
public:
Student(int,char *);
Student()
{
cout<<"调用系统默认构造函数"<<endl;
};
void setname(int,char *);
int Getage();
char *Getname();
};
Student::Student(int m,char *n)
{
cout<<"调用自定义构造函数"<<endl;
age=m;
name=n;
}
int Student::Getage()
{
return age;
}
char * Student::Getname()
{
return name;
}
void Student::setname(int m,char *n)
{
age=m;
name=n;
}
int main()
{
int i;
char mo,ww;
Student stu[3]={Student(20,"ww")};
stu[2].setname(18,"mo");
for(i=0;i<3;i++)
{
cout<<"学生的年龄是:"<<stu[i].Getage()<<"学生的姓名是:"<<stu[i].Getname()<<endl;
return 0;
}