System stack,activation frame,activation frame as the storage for local
auto objects and for function arguments. Passing arguments by value
as opposed to by reference. Calling sequence. Recursion and its relation
to activation frames and the system stack. The price of recursion.
系统堆栈、激活帧、作为本地自动对象的和函数参数的存储激活帧.
按值传递参数而不是通过引用.调用顺序.递归及其与激活帧和系统堆栈的关系.
递归的代价.
Any program of even modest complexity must be modularized for many
reasons: readability, testability, validation, extendibility, maintainability,
and many others, all outside the scope of this book. However, we assume
that the reader understands that any reasonable programming language
must allow for some modularization; C and C++ are no exceptions. Besides
modularization on the level of source files, virtually the only modularization
feature of C consists of structuring a program into separate
functions. The object orientation of C++ allows for a more complex and
far better-controlled modularization.
对于许多人来说,任何稍微复杂的程序都必须模块化
,其原因有:可读性,可测试性,验证性,可扩展性,可维护性,
还有许多其他的,都超出了本书的范围.然而,我们假设读者理解任何合理的编程语言
必须考虑一些模块化,C和C++也不例外.是在源文件的层次上进
行模块化,这实际上是唯一的模块C语言的通用化特点是将一个
程序结构化为单独的功能.C++的对象定位允许更复杂的更好的
控制模块化.
A C/C++ function is a programming module with a precisely defined
interface that consists of the function’s header, which specifies the function’s name,
the data types of the arguments (the input to the function –
though it is possible for a function not to have any arguments), and the
data type of a single return value (the output of the function; again, it
is possible for a function to return nothing at all). Let us observe that
computer scientists prefer to speak of procedures (if no value is returned)
and functions (if a value is returned and the execution has no “side effects”,
meaning that it does not modify any data not local to the function).
However, we shall employ the usual C/C++ terminology and call them
all functions regardless of whether or not a value is returned or any side
effects occur. Similarly, the input to procedures and functions are generally called parameters,
yet we will use the more traditional C/C++ term arguments.
C/C++函数是一个具有精确定义的接口,该接口由函数的头组成,该头指定函数的名称,
参数的数据类型(函数的输入——虽然函数可能没有任何参数),
单个返回值的数据类型(函数的输出,同样,它可能完全不返回任何内容).让我们观察一下
计算机科学家更喜欢谈论过程(如果没有返回值)和函数(如果返回值且执行没有"副作用",
这意味着它不会修改任何非函数本地的数据).然而,无论是否返回值或任何一方影响会发生,
我们将使用常用的C/C++术语并称之为函数.类似地,过程和函数的输入通常称为参数,
然而,我们将使用更传统的C/C++术语参数。
|