0
我正在寫一個快速程序來重新熟悉C++,但是我的開關(選擇){案例「A」:break;}行。類型'const char [2]'的值不能隱式轉換爲'int'錯誤C++
[價值型「爲const char [2]」不是隱式轉換爲「廉政」]
如果有人可以幫助我理解爲什麼我得到這個錯誤,以及如何糾正它,將不勝感激。謝謝!
錯誤的圖片:http://imgur.com/a/d2A0P
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
char printMenuChoice(char choice);
void printSpace(){
cout << endl;
}
int main(){
//Print Menu Choice
char choice;
choice = printMenuChoice(choice);
cout << "Choice is " << choice << endl;
switch(choice){
case "A":
break;
}
//Attack
//Chop
//Shop
//Stats
//Exit
}
char printMenuChoice(char choice){
cout << "[]--- Welcome to Quick Quests ---[]" << endl;
printSpace();
cout << "Attack <A>" << endl;
cout << "Chop <B>" << endl;
cout << "Shop <C>" << endl;
cout << "Exit <E>" << endl;
printSpace();
cout << "Input Your Choice: ";
printSpace();
cin >> choice;
choice = toupper(choice);
return choice;
}
謝謝!我一邊使用GML語言,一邊認爲這是除了//和/ * * /之外的另一種評論方式。 –