-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Ben Shen edited this page Feb 23, 2019
·
12 revisions
-
- INCLUDING Logical AND operator
&&
, Logical OR operator||
, Conditional operator?
- INCLUDING Logical AND operator
-
For class
iteration_statement
- constructor for both
While
andDo While
are BOTH Expression FIRST, then statement
- constructor for both
-
Scope for
for
,while
loop ref- As is the case with
while
loop, if statement is a single statement (not a compound statement), the scope of variables declared in it is limited to the loop body as if it was a compound statement.
for (;;) int n; // n out of scope
- While in C++, the scope of the init-statement and the scope of statement are one and the same, in C the scope of statement is nested within the scope of init-statement:
for (int i = 0; ; ) { long i = 1; // valid C, invalid C++ // ... }
- As is the case with
-
type cast are RIGHT_associative
unsigned char x= 255; std::cout << (int)x << "!\n"; // unsigned char -> unsigned int -> int (NOT SURE, default case), return 255 std::cout << (int)(signed char)x << "!\n"; unsigned char -> char -> int, return -1
-
function declaration vs prototype ref
- A non-prototype declaration does not say anything about parameters.
- Prototype is a declaration that describes the number and the types of function parameters.
int foo(); //declaration int foo(void); //prototype int foo(int a, double b); //prototype int foo(int, double); //prototype