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; } }
Related Posts:
- What does the question mark character (‘?’) mean in C++?
- Does Python have a ternary conditional operator?
- What exactly does += do in python?
- Use of “instanceof” in Java [duplicate]
- Does Python have a ternary conditional operator?
- What are XAND and XOR
- ^=, -= and += symbols in Python
- What does ‘&’ do in a C++ declaration?
- assignment operator overloading in c++
- Error: “expression must have integral or unscoped enum type” [duplicate]
- Logical XOR operator in C++?
- proper name for python * operator?
- What does the percentage sign mean in Python
- Not equal to != and !== in PHP
- What is ‘\0’ in C++?
- What is a Question Mark “?” and Colon “:” Operator Used for?
- What does the percentage sign mean in Python
- What does =~ do in Perl?
- error: ‘ostream’ does not name a type
- Multiple OR or AND conditions in IF statement
- Difference between “or” and || in Ruby?
- Class template inheritance C++
- What is the difference between the dot (.) operator and -> in C++?
- Difference between “and” and && in Ruby?
- The tilde operator in C
- How do you use the ? : (conditional) operator in JavaScript?
- How to create a dynamic array of integers
- How to implement 2D vector array?
- What is meant with “const” at end of function declaration? [duplicate]
- What’s the C++ version of Java’s ArrayList
- What is the difference between “long”, “long long”, “long int”, and “long long int” in C++?
- Creating a “logical exclusive or” operator in Java
- What are the rules of the std::cin object in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- How do I convert a double into a string in C++?
- How to create timer events using C++ 11?
- How to concatenate two strings in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- Read file line by line using ifstream in C++
- Segmentation Fault (core dumped) C++
- C++ – No matching member function for call to ‘push_back’
- error: lvalue required as unary & operand
- C/C++ JSON parser
- C++ Parsing input string to variables
- ‘cout’ was not declared in this scope
- Segmentation fault error 11 C++
- How to convert a single char into an int [duplicate]
- A proper way to create a matrix in c++
- Exception Handling in C++ Terminate called after throwing an instance of ‘char const*’
- How to deal with bad_alloc in C++?
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- Thread pooling in C++11
- Callback functions in C++
- Reading from text file until EOF repeats last line
- How does std::forward work? [duplicate]
- Examples of good gotos in C or C++
- Sleep function in C++
- Error: Jump to case label in switch statement
- What does int & mean
- Split a string into an array in C++
- splitting a string into an array in C++ without using vector
- Remove spaces from std::string in C++
- How to use glOrtho() in OpenGL?
- What does the colon (:) operator do?
- Is there an exponent operator in C#?
- Remove spaces from std::string in C++
- Read data from a file into an array – C++
- Unknown override specifier, missing type specifier
- #pragma once vs include guards?
- Debug vs Release in CMake
- C++ Remove punctuation from String
- PHP if not statements
- prototype for “….” does not match any in class “…”
- Cannot open Windows.h in Microsoft Visual Studio
- Nested For – Loops to create multiplication table C++
- How can I get and use the header file
in my C++ program? - cin.eof() functionality
- Implementing a tree in C++
- Drawing Circle with OpenGL
- Run-Time Check Failure #2 – Stack around the variable ‘foo’ was corrupted
- How to implement “Press Any Key To Exit”
- Reading and writing binary file
- C++ : Exception occurred in script: basic_string::_S_construct NULL not valid
- Error: “expected primary-expression before int”
- Xcode 11.1: iostream’ file not found
- non-member function cannot have cv-qualifier
- too many initializers for ‘int [0]’ c++
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- Why do I get: -9223372036854775808
- Return a 2d array from a function
- Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file
- What is the difference among ios::app, out, and trunc in c++?
- Using OR operator in a jQuery if statement
- Where can I find ‘winmm.lib’ (I’m using Visual Studio 2012)
- What is a `char*`?
- Does static constexpr variable inside a function make sense?
- “Incomplete type not allowed ” when creating std::ofstream objects
- CSS “and” and “or”