- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
第6章 函数设计(The sixth chapter, function design)
第6章 函数设计(The sixth chapter, function design)
The sixth chapter, function design
Function is the basic functional unit of C++/C program, and its importance is self-evident. Minor points of function design is very easy to cause the function to be misused, so light to function correctly is not enough. This chapter focuses on the function of the interface design and internal implementation of some of the rules.
The two elements of a function interface are arguments and return values. In the C language, there are two ways of passing the arguments and return values of functions: by (pass, value, pointer) and by (pass). In the C++ language, there is more reference by (pass). Since the nature of reference delivery is like pointer passing, the use of style is like value passing, and beginners are often confused and prone to confusion. Read the 6.6 section, compare references to pointers..
Rule of 6.1 parameters
L [rule 6-1-1] the writing of the parameter should be complete, do not seek to save trouble, just write the type of parameter, and omit parameter name. If the function has no arguments, fill it with void.
Such as:
Void SetValue (int width, int height); / / good style
Void SetValue (int, int); / / bad style
Float GetValue (void); / / good style
Float (GetValue); / / bad style
L [rule 6-1-2] parameter names should be appropriate and ordered in order.
For example, write string copy function StringCopy, which has two arguments. If you name the parameters as STR1 and STR2, for example
Void StringCopy (char, *str1, char, *str2);
Well, its hard to know whether to copy STR1 to STR2 or just to reverse it.
You can make parameter names more meaningful, such as strSource and strDestination. Thus, you can see from the name that you should copy strSource to strDestination.
One more question, which of these two parameters should be in the front and the other behind? The order of the parameters follows the programmers habits. In general, you should put the destination parameter in fr
您可能关注的文档
- 淮北地区山药炭疽病的发生特点及防治技术(Occurrence characteristics and control techniques of yam Anthracnose in Huaibei area).doc
- 淮北首家民营企业管理企业年金花落祥泰科技(Huaibei's first private enterprise in the golden flowers Xiangtai Technology).doc
- 液晶面前,谁在狂舞(The liquid crystal in front, who in the dance).doc
- 淮南牛肉汤(Huainan beef soup).doc
- 淮南矿业集团较严重 三违行为界定(Huainan Mining Group is serious three violations behavior).doc
- 淮扬后(Huaiyang after).doc
- 混凝土冲孔灌注桩工作要点(Main points of concrete punching bored pile).doc
- 混凝土及砌体结构02(Concrete and masonry structures 02).doc
- 混凝土后浇带(Concrete back pouring band).doc
- 混凝土在现代建筑施工中的应用分析编辑(Analysis and application of concrete in modern building construction).doc
- 第8章 电子商务项目与项目管理软件(The eighth chapter is e-commerce project and project management software).doc
- 第4课 夏、商、西周的兴亡(The rise and fall of fourth class Xia, Shang and Western Zhou Dynasty.).doc
- 空资料主板(Null data board).doc
- 第9章 竞争性市场营销战略(The ninth chapter is competitive marketing strategy).doc
- 第一批异形词整理表(The first batch of odd word sorting tables).doc
- 第一单元硫酸的制备和性质(Unit 1 Preparation and properties of sulphuric acid).doc
- 第一章 绪 论(The first chapter is introduction).doc
- 第13章-多电机拖动系统(The thirteenth chapter - multi motor drive system).doc
- 第一节 隋唐时期的文教政策(Section 1 cultural and educational policies in Sui and Tang Dynasties).doc
- 第一节 单纯性下肢静脉曲张(Section 1 simple varicose veins of the lower extremities).doc
原创力文档


文档评论(0)