设为首页 加入收藏

TOP

7. FUNCTIONS
2013-10-07 15:25:55 来源: 作者: 【 】 浏览:63
Tags:FUNCTIONS

CONTENTS

Section 7.1 Defining a Function . . . . . . . . . . . . . 226

Section 7.2 Argument Passing . . . . . . . . . . . . . . 229

Section 7.3 The returnStatement . . . . . . . . . . . . 245

Section 7.4 Function Declarations . . . . . . . . . . . . 251

Section7.5 LocalObjects . . . . . . . . . . . . . . . . . 254

Section7.6 InlineFunctions . . . . . . . . . . . . . . . . 256

Section 7.7 ClassMember Functions . . . . . . . . . . 258

Section 7.8 Overloaded Functions . . . . . . . . . . . . 265

Section 7.9 Pointers to Functions . . . . . . . . . . . . . 276

ChapterSummary . . . . . . . . . . . . . . . . . . . . . . 280

DefinedTerms . . . . . . . . . . . . . . . . . . . . . . . . . 280

This chapter describes how to define and declare functions. We’ll cover how arguments are passed to and values are returned from a function. We’ll then look at three special kinds of functions: inline functions, class member functions, and overloaded functions. The chapter closes with a more advanced topic: function pointers.

函数是程序组织的基本单元。从本章开始,C++(www.cppentry.com)的一些特性开始体现出来。本章用了约20 页的篇幅来讲解函数调用时的实参传递(俗称参数传递、传参)和return 语句。这部分内容非常重要,特别是当参数类型或函数返回类型是class类型时,C++(www.cppentry.com) 的行为非常独特,值得认真学习。

A function can be thought of as a programmer-defined operation. Like the built-in operators, each function performs some computation and (usually) yields a result. Unlike the operators, functions have names and may take an unlimited number of operands. Like operators, functions can be overloaded, meaning that the same name may refer to multiple different functions.

本书严格区分形参(parameter)和实参(argument)这两个术语,前者就像函数的局部变量,后者是调用函数时传入的数据;或者说,形参是变量声明,而实参是表达式。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2.7 Enumerations 下一篇7.1.1 Function Return Type

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·python数据分析岗的 (2025-12-25 10:02:21)
·python做数据分析需 (2025-12-25 10:02:19)
·成为一个优秀的pytho (2025-12-25 10:02:16)
·Java后端面试实习自 (2025-12-25 09:24:21)
·Java LTS版本有哪些 (2025-12-25 09:24:18)