特定数组索引的增量值 [英] increment value for the particular array index
本文介绍了特定数组索引的增量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了一个数组计数器作为Count [15] =0.我想为诸如Count [10] ++之类的特定索引增加计数器.这是有效的陈述吗?或执行其他操作的其他任何方式.
I used an array counter as Count[15] = 0. I want to increment the counter for the particular index like Count[10]++. Is this valid statement or not? Or any other way to do same thing.
推荐答案
是的.这是一个有效的语句.
Yes. It''s a valid statement.
当然是有效的.
另一种选择是
Of course it is valid.
An alternative would be
Count[10] = Count[10] + 1;
通过执行此更改,我得到以下错误:
错误C2440:正在初始化":无法从"const int"转换为"int [18]"
我将计数变量定义为"static int Count [MAX_STATION_NO + 2] = 0;"
by doing this change I got following error:
error C2440: ''initializing'' : cannot convert from ''const int'' to ''int [18]''
I defined the count variable as "static int Count[MAX_STATION_NO+2] = 0;"
这篇关于特定数组索引的增量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文