What does the question mark character (‘?’) mean in C++?

This is commonly referred to as the conditional operator, and when used like this:

condition ? result_if_true : result_if_false

… if the condition evaluates to true, the expression evaluates to result_if_true, otherwise it evaluates to result_if_false.

It is syntactic sugar, and in this case, it can be replaced with

int qempty()
{ 
  if(f == r)
  {
      return 1;
  } 
  else 
  {
      return 0;
  }
}

Leave a Comment