#include <iostream>
using namespace std;
int fn1 (){
int a = 5;
int b = 6;
cout << (++a > b--)? (a+b):(a-b) ;
a = 5;
b = 6;
return (++a > b--)? (a+b):(a-b);
}
int main (){
cout << fn1();
}
// Output: 01
Operator precedence.
cout << (++a > b--)? (a+b):(a-b);
is parsed as:
(cout << (++a > b--))? (a+b):(a-b);
which first evaluates the cout <<
then the rest.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.