当我尝试运行此程序时,我一直在收到无限循环错误。任何人都可以帮助我并告诉我为什么?任何援助将不胜感激。谢谢!C++中的无限循环
void Increment(int);
int main()
{
int count = 1;
while(count < 10)
cout << "the number after " << count; //Increment function
Increment(count); //count+1
cout << " is " << count << endl;
return 0;
}
void Increment (int nextNumber)
{
nextNumber++; //parameter +1
}
你局部地改变它 - 通过引用传递! – Maroun
为什么你不直接做nextNumber ++而不是将它作为一个函数? – Borgleader
这也是他的一段时间的声明。它没有括号。 –