groups

name language licence
enum - array of labelled values C++ Other
Print a TCut C++ Other
Ternery operator / conditional expression C++ Other
Maximum likelihood, minuit example C++ Other
Commenting code including comments C++ Other
Convert string to integer C++ Other
Distance from a point to a line C++ Other



language: C++
licence: Other

Ternery operator / conditional expression

options: view full snippetsend to code collector

// Syntax :

variable = condition ? value if true : value if false

// Using the ? operator :

int opening_time = (day == WEEKEND) ? 12 : 9;

// Without using the ? operator :

int opening_time;
 
if (day == WEEKEND)
    opening_time = 12;
	
(Continues...)