第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么我改成Month month3("Jan"); 也不行?

為什么我改成Month month3("Jan"); 也不行?

C++
狐的傳說(shuō) 2023-03-18 14:10:24
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]); //別的函數(shù)我就不寫(xiě)了}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'});這里總是報(bào)錯(cuò) 說(shuō)no matching constructor for initialization of 'Month'我改成Month month3("Jan"); 也不行說(shuō)ISO C++11 does not allow conversion from string literal to 'char'
查看完整描述

2 回答

?
幕布斯6054654

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超7個(gè)贊

參數(shù)不對(duì),“Jan”是個(gè)string類型,而你的類里參數(shù)類型是指針類型,你可以先char *ch="Jan";然后調(diào)用構(gòu)造函數(shù),Month month3(ch);

查看完整回答
反對(duì) 回復(fù) 2023-03-21
?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

這里總是報(bào)錯(cuò) 說(shuō)no matching constructor for initialization of 'Month' 

是說(shuō)你沒(méi)有構(gòu)造函數(shù)。
SO C++11 does not allow conversion from string literal to 'char'

是說(shuō)不允許從string 到char

查看完整回答
反對(duì) 回復(fù) 2023-03-21
  • 2 回答
  • 0 關(guān)注
  • 108 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)