我是C++新手。我試圖根據在cin中選擇的數字爲一個月分配一個字符串。 這是我在一個函數中的代碼。C++在if語句中分配字符串變量
cout << "Enter your birth month: ";
cin >> mm; //Birth Month//
int mm;
std::string month;
if(mm == 5 || mm == 05){
std::string month = "May";
}
// If month is equal to 5 or 05, set string variable month to May
cout << "You were born in the month of " << month << endl;
如果mm等於5,我如何將變量「month」賦值給「may」?
你的問題是什麼? – Borgleader 2015-01-15 17:35:21
對不起,如果我是一個很模糊。編輯 – 2015-01-15 17:36:26
「我認爲......」爲什麼假設而不是查找它? – crush 2015-01-15 17:36:31