dev和visual studio都不行,改变语言符合模式没用,主函数体参数改变也没用,const求教,本来是因为学构造函数随便写了个程序,结果好多错啊,注释掉的是因为不会改,先放一边了,还有char数组赋值的那个,也请求大佬指点,
#include <iostream>
using namespace std;
#include<string.h>
class dormitary {
public:
char name[30];
int number;
public:
dormitary(char c[], int a) {
name= c;
number = a;
cout << "调用有参构造函数" << endl;
}
dormitary() {
//const void class name = "xiyangyang";
number = 1234;
cout << "调用无参构造函数" << endl;
}
~dormitary() {
cout << "调用析构函数" << endl;
}
};
int main(int argc,char **argv)
{
dormitary p1;
p1.name = {"xiaoming"} ;
p1.number = 19;
cout << p1.name << endl;
}
求大佬指点,感恩