- Because the condition is not evaluated until after the statement or block is executed,thedo while loop does not allow variable definitions inside the condition:
do { // . . . mumble(foo); } while (int foo = get_foo()); // error: declaration in a do condition
- 对于连续的cin,如果其中一个输入发生错误,后面的cin将不会再执行。
- Using reference to avoid copies
- Using reference parameters to return additional information
- Using reference to const when possible
-
Even though we cannot pass an array by value, we can write a parameter that looks like an array:
// despite appearances, these three declarations of print are equivalent // each function has a single parameter of type const int* void print(const int*); void print(const int[]); // shows the intent that the function takes an array void print(const int[10]); // dimension for documentation purposes (at best)
5.4Iterative statement &6.2Argument passing
最新推荐文章于 2024-08-16 07:46:43 发布