Test0911a.cpp:Defines the entry point for the console application.
#include "stdafx.h" #include <iostream> using namespace std;
int main (int argc, char* argv[]) {printf ("--------------> Hello world!\n");
int a = 0; if (a++ && a) cout<< "a++ && A is true, a =" <<a<<endl; There is no output else cout<< "a++ && A is false, a =" <<a<<endl;//output, and a = 1;
When judging (a++) First use a (value of 0) to judge as false, and then do not continue the int b = 0; if (b++) cout<< "b++ is true, B =" <<b<<endl; There is no output else cout<< "b++ is false, B =" <<b<<endl;
Output, and b = 1 int c=1; if (--c) cout<< "--c true, c=" <<c<<endl; There is no output else cout<< "--c is False, c=" <<c<<endl;//output, and c=0;
Judgment (--C) is to do a minus 1 calculation, in the use of C value (0) to determine the int d=0; if (++d) cout<< "++d true, d=" <<d<<endl;
output, and d=1; else cout<< "++d is False, d=" <<d<<endl;
no output int e=0; if (++e && e) cout<< "++e && E is true, e=" <<e<<endl; Output, and E =1 else cout<< "++e && E is false, e=" <<e<<endl;
No output return 0;
}
Ps:
Similar to C + + Primer (Fourth edition) Exercise solution, Page 61, Exercise 5.29