The C in C++

1 unnamed arguments in the argument list of the function definition    (Page 114)

In c++, an argument may be unnamed in the argument list of the function definition. Since it is unnamed , you cannot use it in the function body, of course. Unnamed arguments are allowed to give the programmer a way to "reserve space in the argument list." Whoever uses the function must still call the function with the proper arguments. However, the person creating the function can then use the argument in the future without forcing modification of code that calls the function.

2 numbers of arguments       (Page 114)

2.1 an empty argument list

func():   In C++, it tells the compiler there are exactly zero arguments.

     In C, it means an indeterminate number of arguments.

func(void):  In C and C++, it means an empty argument list.

2.2 a variable argument list

func(...):  you should restrict your use of variable argument lists in C and avoid them in C++.

3 Introduction to the pointers

Each of the elements in the program has a location in storage when the program is running. Even the function occupies storage.

4 Specifying storage allocation    (Page 147)

gloal variables,

local variables,

register variables(avoided),

static variables(it is unavailable outside its definition scope, such as function scope or file scope. And you can define a function's local variable to be static and give it an initial value, the initialization is performed only the first time the function is call, and the data retains its value between function calls),

extern variables,

constants variables(a const must always hava an initialization value, and its value never change),

volatile variables(you will never know when this will change, and prevents the compiler from performing any optimizations based on the stability of that variable),

5 function address    (Page 198)

Once a function is compiled and loaded into the computer to be executed, it occupies a chunk of memory. Thus the funciton has an address.

When you are looking at a complex definition, the best way to attack it is to start in the middle and work your way out. middle->right->left->right->

 

posted @ 2014-04-22 17:12  ruccsbingo  阅读(261)  评论(0编辑  收藏  举报