-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
  • 124,179
  • 11
  • 158
  • 228
purpleminion
  • 87
  • 1
  • 1
  • 8

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
  • 124,179
  • 11
  • 158
  • 228
0

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

while (!stuff && otherstuff) {

}
Dietrich Epp
  • 194,726
  • 35
  • 326
  • 406