无效的转换。 [-fpermissive]" in my source code. #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main () { //Suits const string suitList[4] = { "Spades", "Hearts", "Clubs", "Diamonds" }; string suit = suitList[rand() % 4]; //int suit = //rand ()"Spades", "Hearts", "Clubs", "Diamonds"; //Faces char faceList[13] = {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ; char face = faceList[rand() % 13]; //int face = // rand ()"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "Queen", "Jack"; //Dealer string Deal; cout << "Type Deal for a card: "; cin >> Deal; cout << "Your card is the " << face << " of " << suit; return 0; } [-fppermission]“在我的源代码中。 #包括 #包括 #包括 #包括 使用名称空间std; int 主要() { //适合 const string suitList[4]={“黑桃”、“红桃”、“梅花”、“钻石”}; 字符串suit=suitelist[rand()%4]; //内服= //兰德()“黑桃”、“红桃”、“梅花”、“钻石”; //面孔 char faceList[13]={'2','3','4','5','6','7','8','9','10','Ace','King','Queen','Jack'}; char face=faceList[rand()%13]; //内面= //兰特()“2”、“3”、“4”、“5”、“6”、“7”、“8”、“9”、“10”、“王牌”、“国王”、“女王”、“杰克”; //经销商 串交易; 交易; cout,c++,C++" /> 无效的转换。 [-fpermissive]" in my source code. #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main () { //Suits const string suitList[4] = { "Spades", "Hearts", "Clubs", "Diamonds" }; string suit = suitList[rand() % 4]; //int suit = //rand ()"Spades", "Hearts", "Clubs", "Diamonds"; //Faces char faceList[13] = {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ; char face = faceList[rand() % 13]; //int face = // rand ()"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "Queen", "Jack"; //Dealer string Deal; cout << "Type Deal for a card: "; cin >> Deal; cout << "Your card is the " << face << " of " << suit; return 0; } [-fppermission]“在我的源代码中。 #包括 #包括 #包括 #包括 使用名称空间std; int 主要() { //适合 const string suitList[4]={“黑桃”、“红桃”、“梅花”、“钻石”}; 字符串suit=suitelist[rand()%4]; //内服= //兰德()“黑桃”、“红桃”、“梅花”、“钻石”; //面孔 char faceList[13]={'2','3','4','5','6','7','8','9','10','Ace','King','Queen','Jack'}; char face=faceList[rand()%13]; //内面= //兰特()“2”、“3”、“4”、“5”、“6”、“7”、“8”、“9”、“10”、“王牌”、“国王”、“女王”、“杰克”; //经销商 串交易; 交易; cout,c++,C++" />

";从‘;常量字符*’;至‘;char’;[-FPPermissive]错误“;不会消失的 我刚开始学习C++,我有一个问题,“从‘const char’到‘char’< /p>无效的转换。 [-fpermissive]" in my source code. #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main () { //Suits const string suitList[4] = { "Spades", "Hearts", "Clubs", "Diamonds" }; string suit = suitList[rand() % 4]; //int suit = //rand ()"Spades", "Hearts", "Clubs", "Diamonds"; //Faces char faceList[13] = {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ; char face = faceList[rand() % 13]; //int face = // rand ()"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "Queen", "Jack"; //Dealer string Deal; cout << "Type Deal for a card: "; cin >> Deal; cout << "Your card is the " << face << " of " << suit; return 0; } [-fppermission]“在我的源代码中。 #包括 #包括 #包括 #包括 使用名称空间std; int 主要() { //适合 const string suitList[4]={“黑桃”、“红桃”、“梅花”、“钻石”}; 字符串suit=suitelist[rand()%4]; //内服= //兰德()“黑桃”、“红桃”、“梅花”、“钻石”; //面孔 char faceList[13]={'2','3','4','5','6','7','8','9','10','Ace','King','Queen','Jack'}; char face=faceList[rand()%13]; //内面= //兰特()“2”、“3”、“4”、“5”、“6”、“7”、“8”、“9”、“10”、“王牌”、“国王”、“女王”、“杰克”; //经销商 串交易; 交易; cout

";从‘;常量字符*’;至‘;char’;[-FPPermissive]错误“;不会消失的 我刚开始学习C++,我有一个问题,“从‘const char’到‘char’< /p>无效的转换。 [-fpermissive]" in my source code. #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main () { //Suits const string suitList[4] = { "Spades", "Hearts", "Clubs", "Diamonds" }; string suit = suitList[rand() % 4]; //int suit = //rand ()"Spades", "Hearts", "Clubs", "Diamonds"; //Faces char faceList[13] = {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ; char face = faceList[rand() % 13]; //int face = // rand ()"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "Queen", "Jack"; //Dealer string Deal; cout << "Type Deal for a card: "; cin >> Deal; cout << "Your card is the " << face << " of " << suit; return 0; } [-fppermission]“在我的源代码中。 #包括 #包括 #包括 #包括 使用名称空间std; int 主要() { //适合 const string suitList[4]={“黑桃”、“红桃”、“梅花”、“钻石”}; 字符串suit=suitelist[rand()%4]; //内服= //兰德()“黑桃”、“红桃”、“梅花”、“钻石”; //面孔 char faceList[13]={'2','3','4','5','6','7','8','9','10','Ace','King','Queen','Jack'}; char face=faceList[rand()%13]; //内面= //兰特()“2”、“3”、“4”、“5”、“6”、“7”、“8”、“9”、“10”、“王牌”、“国王”、“女王”、“杰克”; //经销商 串交易; 交易; cout,c++,C++,这条线: char faceList[13] = {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ; 无法工作,因为您正在混合chars和const char*,它们类似于字符串 您可以将它们全部设置为字符串: string faceList[13] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "

这条线:

char faceList[13] =  {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ;
无法工作,因为您正在混合
char
s和
const char*
,它们类似于字符串

您可以将它们全部设置为字符串:

string faceList[13] =  {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "Queen", "Jack" } ;
理想情况下,完全避免使用数组,只需使用以下行:

char faceList[13] =  {'2', '3', '4', '5', '6', '7', '8', '9', "10", "Ace", "King", "Queen", "Jack" } ;
无法工作,因为您正在混合
char
s和
const char*
,它们类似于字符串

您可以将它们全部设置为字符串:

string faceList[13] =  {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace", "King", "Queen", "Jack" } ;

理想情况下,完全避免使用数组,只需使用
std::vector

char faceList[13]
是一个字符数组,但初始值设定项列表中的某些元素显然是字符串。这不可能。我的建议是,如果允许使用
std::string
,请优先使用
char[]
。如果你有
c++17
,你可能也对
std::string\u视图
char faceList[13]
是一个字符数组,但是你的初始值设定项列表中的一些元素显然是字符串。这是行不通的。我的建议是,如果你被允许使用
std::string
而不是
char[]
。如果您有
c++17
,您可能还对
std::string\u视图感兴趣