一个关于类定义的菜问题?但我看了半天也不知道哪里错了!
#include <iostream.h>
#include <string.h>
class Student
{
private:
char name[20];
public:
Student(char *pname)
{
cout<<"constructing student"<<pname<<endl;
strncpy(name,pname,sizeof(name));
name[sizeof(name)-1]='\0';
}
~Student()
{
cout<<"destructing"<<name<<endl;
}
}
int main()
{
Student cs("tmp") ; //这里编译时出错!!!
return 0;
}