为什么VC不行
#include <string.h>
class student
{
char name[33];
public:
student() {}
student (char *p)
{
strcpy(name,p);
name[sizeof(name)-1]='\0';
}
};
#include <iostream.h>
void()
{
student st[2]("zhang","lisi");
}
#include <iostream.h>
#include <string.h>
class student
{
char name[33];
public:
student() {}
student (char *p)
{
strcpy(name,p);
name[sizeof(name)-1]='\0';
}
void display()
{
cout<<name<<endl;
}
};
void main()
{
student st[2]={"zhang","lisi"}; //你这个搞错了!!
st[0].display();
st[1].display();
}
对数组的赋值就应该是A[n]={"","",""...""};