急,帮我看看这个程序为什么有错误?
李赞红 2004-12-23 09:38:02 调用show()的时候就有问题了.
#include<string.h>
#include<iostream.h>
class Student
{
private:
char* name;
int age;
public:
Student(char n,int a)
{
name = new char[strlen(n) + 1];
strcpy(name,n);
age = a;
}
Student()
{
Student("lzh",0);
}
void show()
{
cout << name << endl;
cout << age << endl;
}
};
void main()
{
Student s1;
s1.show();
}