第4章函数与预处理 4.1概述 4.2 定义函数的一般形式 4.3 函数参数和函数的值 4.4函数的调用 *4.5 内置函数 *4.6 函数的重载 *4.7 函数模板 *4.8 看款认参数的函数 4.9函数的嵌套调用 4.10函数的递归调用 4.11局部变量和全高变量 4.12 变量的存储类别 4.13 变量属性小结 4.14 笑于变量的声明和定义 4.15 丙部函数和外部函数 4.16 预处理命令 017年4月26日12时17分 HOME 第4章函数与预处理 2 BACK NEXT
HOME2017年4月26日12时17分 第4章 函数与预处理 2 4.1 概述 4.2 定义函数的一般形式 4.3 函数参数和函数的值 4.4 函数的调用 *4.5 内置函数 *4.6 函数的重载 *4.7 函数模板 *4.8 有默认参数的函数 4.9 函数的嵌套调用 4.10 函数的递归调用 4.11 局部变量和全局变量 4.12 变量的存储类别 4.13 变量属性小结 4.14 关于变量的声明和定义 4.15 内部函数和外部函数 4.16 预处理命令
runctlon rreprocessor directives Main Content Function's definition,declaration and call Parameters transfer between functions Function's overloading Function template Functions with default format parameters Function's Nesting call Function's Recursion call 2017年4月26日12时17分 3 HOM正 第4章函数与预处理 BACK NEXT
HOME2017年4月26日12时17分 第4章 函数与预处理 3 Main Content • Function’s definition, declaration and call • Parameters transfer between functions • Function’s overloading • Function template • Functions with default format parameters • Function’s Nesting call • Function’s Recursion call
函数(function)概述 C++的函数(function)是完成既定任务的功能(过 程)体,它涵盖了数学函数和一般过程.所以基于 过程编程本质上就是基于函数编程。 为了便于规划、组织、编程和调试,一 般的做法是 把一个大的程序划分为若干个程序模块(即程序文件), 每一个模块实现一部分功能。 在程序进行编译时,以程序模块为编译单位,即分 别对每一个编译单位进行编译。如果发现错误,可 以在本程序模块范围内查错并改正 2017年4月26日12时17分 第4章函数与预处理 BAC
HOME2017年4月26日12时17分 第4章 函数与预处理 4 C++的函数(function)是完成既定任务的功能(过 程)体,它涵盖了数学函数和一般过程.所以基于 过程编程本质上就是基于函数编程。 为了便于规划、组织、编程和调试,一般的做法是 把一个大的程序划分为若干个程序模块(即程序文件), 每一个模块实现一部分功能。 在程序进行编译时,以程序模块为编译单位,即分 别对每一个编译单位进行编译。如果发现错误,可 以在本程序模块范围内查错并改正
1 Function's Definition Function is the basic abstract module in OOP,and it also is abstract for some tasks. Syntax Form of function definition: 类型标识符 函数名(形式参数表) 若无参数,写void 语句序列 是被初始化的内部 变量,寿命和可见 性仅限于函数内部 若无返回值,写void 017年4月26日12时17分 第4章函数与预处理 5 HOME BACK NEX
HOME2017年4月26日12时17分 第4章 函数与预处理 5 • Function is the basic abstract module in OOP, and it also is abstract for some tasks. • Syntax Form of function definition: 类型标识符 函数名(形式参数表) { 语句序列 } 若无参数,写void 是被初始化的内部 变量,寿命和可见 性仅限于函数内部 若无返回值,写void
Format parameter list <type>name1,<type2>name2,...<typen> namen Return value of function Given by return sentence.For example: 。return0; 。return 4(1); If the function has no return value,which means void type,the return sentence can be omitted. 2017年4月26日12时17分 HOM正 第4章函数与预处理 6 BACK NEXT
HOME2017年4月26日12时17分 第4章 函数与预处理 6 • Format parameter list <type1> name1 , <type2> name2 , ..., <typen> namen • Return value of function – Given by return sentence. For example: • return 0; • return (1); – If the function has no return value, which means void type,the return sentence can be omitted