【发布时间】:2016-03-05 18:31:06
【问题描述】:
这段代码有什么问题?为什么循环条件重复执行而循环体从不重复执行?它快把我逼疯了!我看不到问题:
bool test() { std::cout << "condition!" << std::endl; return true; }
while(test());
{
std::cout << "This message never appears!!!" << std::endl;
}
输出:
condition!
condition!
condition!
...forever
【问题讨论】:
标签: c++ while-loop infinite-loop