当我尝试运行这个程序时,我继续收到无限循环错误.谁能帮帮我,告诉我为什么?任何援助都将非常感激.谢谢!
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
}
Run Code Online (Sandbox Code Playgroud)
你是通过值而不是通过引用传递的:
改为:
void Increment (int& nextNumber)
{
nextNumber++; //parameter +1
}
Run Code Online (Sandbox Code Playgroud)
此外,您缺少while循环的结束括号.
| 归档时间: |
|
| 查看次数: |
886 次 |
| 最近记录: |