- 就算我们知道对应的argument去初始化对应的parameter,但是初始化的Order我们还是不知道
Functions Basics
- Scope: The scope of a name is the part of the program’s text in which that name is visible.
- Lifetime: The lifetime of an object is the time during the program’s execution that the object exists.
Local Objects
- Objects defined outside any function exist throughout the program’s execution.
- The lifetime of a local variable depends on how it is defined. (
static
)
Automatic Objects
就是我们常说的本地变量。但其实本地变量才是大的概念,而我们理解的这个实际上是 “自动变量”。
Local
static
Objects
- lifetime continues across calls to the function. (这里字面意思看上去是生存期是间断连续的,但网上直接说全局的生存期)
- 每次运行到它的作用域时,不用重新定义,直接就是上次的值 (所谓局部作用域)
- 默认初始化为0
Function Declarations
- 由于没有function body,所以也可以省略掉parameter names。但是这个name主要是为了readable
const
可以不加,因为它在声明中完全没有意义 (我的理解是,声明就是告诉别人如何使用,怎么使用,const
加不加对使用者完全没有影响)- The header that declares a function should be included in the source file that defines that function.
Separate Compilation
以后学CMake之后再来学吧