1

I have two functions:

bool f() const
int g() const

The if-statement in question lies within a while loop, as follows:

while(/*get next element*/){
  if ( f() || g() == 5 ) continue;
  // Do some stuff...
}

gdb tells me that f() returns TRUE; however, the continue isn't being executed. The program goes further in the loop body to "do some stuff".

What is the problem here? Is gdb lying to me?

Solution: The previous revision of my code did not include the call to f() in the if-statement. I forgot to recompile, so the source had me believing the call was there, but it wasn't. https://stackoverflow.com/a/19989652/1566525

4

2 に答える 2

0

ifループ内にステートメントがありますか?

cppreference から:

囲んでいる for、range-for、while、または do-while ループ本体の残りの部分をスキップさせます。条件ステートメントを使用してループの残りの部分を無視するのが面倒な場合に使用します。

于 2013-11-14T22:08:17.233 に答える