-4
我想输出这个数组,我不知道我是不是一个白痴,解决方案是盯着我,还是有更多的技术在这里发生。输出二维数组
代码:
for (string i=0;i<row; i++)
{
for (string j=0; j<col; j++)
{
out << Array[i][j];
}
}
请注意,Array
是char
数据类型。 row
和col
被定义为字符串。
我正的错误是从视觉工作室(3个错误):
cpp(97): error C2676: binary '++': 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
cpp(99): error C2676: binary '++': 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
cpp(101): error C2677: binary '[': no global operator found which takes type 'std::string' (or there is no acceptable conversion)
请注意,我试图用整数,而不是为计数器字符串,但我得到了很多错误...
为什么字符串?如果你想增加它,使用一个数字类型,例如'int' – user463035818
因为如果我把'i'和'j'改成int,我会得到更多的错误。 – Bane
“请注意,Array是char数据类型,row和col被定义为字符串。”我很抱歉,但这没有意义,“因为如果我把'i'和'j'改成int,我会犯很多错误,实际上很有趣。无论如何,请提供[mcve]。 – George