c++定义了一个类 在main函数里对变量声明的时候报错
charthree_let[13][4]={"emp","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oc...
char three_let[13][4]={"emp","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
class Month{
private:
int month;
bool check();
public:
Month(char x[3]); //别的函数我就不写了
}
Month::Month(char x[3]){
int i;
for (i=1; i<14; i++) {
if ((strcmp(three_let[i], x)==0)) {
month=i;
break;
}
}
}
int main(){
Month month3({'J','a','n'});
这里总是报错 说no matching constructor for initialization of 'Month'
我改成Month month3("Jan"); 也不行
说ISO C++11 does not allow conversion from string literal to 'char' 展开
class Month{
private:
int month;
bool check();
public:
Month(char x[3]); //别的函数我就不写了
}
Month::Month(char x[3]){
int i;
for (i=1; i<14; i++) {
if ((strcmp(three_let[i], x)==0)) {
month=i;
break;
}
}
}
int main(){
Month month3({'J','a','n'});
这里总是报错 说no matching constructor for initialization of 'Month'
我改成Month month3("Jan"); 也不行
说ISO C++11 does not allow conversion from string literal to 'char' 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询