我必须实施一副带有数字和字母的卡片。这是我到目前为止所做的:
string deck [6][6] =
{
{1A, 1B, 1C, 1D},
{2A, 2B, 2C, 2D},
{3A, 3B, 3C, 3D},
{4A, 4B, 4C, 4D},
{ , , , };
};
int main ()
{
cout << deck[0][0] << endl;
}
我收到错误:
整数常量
上的无效后缀'A'
答案 0 :(得分:0)
您收到此错误是因为您需要将字符串换成双引号。如果要使用静态初始化/声明,它应如下所示:
System/setProperty
您可以使用两个嵌套的std::string deck[4][4] = {
{ "1A", "1B", "1C", "1D"},
{ "2A", "2B", "2C", "2D"},
{ "3A", "3B", "3C", "3D"},
{ "4A", "4B", "4C", "4D"}
};
循环显示卡组的全部内容:
for