-1

I have a c++ while loop I'm looking at:

while ((stuff) ? false : (otherstuff))
{
  commands;
}

And I don't really understand what it's trying to do with the "? false :" part? Can any one explain what this means please? I already tried looking it up but I'm not really getting anything helpful.

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
purpleminion
  • 87
  • 1
  • 1
  • 9

2 Answers2

2

It's using the ternary conditional operator to effectively perform the check:

while (!(stuff) && (otherstuff))

If stuff is true, then the first option on the ternary is evaluated (evaluating to false), if it's false, then it evaluates to otherstuff.

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
0

It's just a really bad way of writing this:

while (!stuff && otherstuff) {

}
Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415