- 1、本文档共19页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
条款34将文件间的编译依赖性降至最低(Clause 34 minimize dependency on compilation between files)
条款34将文件间的编译依赖性降至最低(Clause 34 minimize dependency on compilation between files)
Clause 34: minimizes the dependency on compilation between files
Suppose you open your C++ program code one day and then make minor changes to the implementation of a class. Remind you that the change is not the interface, but the implementation of the class, that is, the details. Then you are ready to regenerate the program, thinking that the compilation and linking should take only a few seconds. After all, its just a class changed! So you clicked on Rebuild or entered make (or something like that). Yet what awaits you is astonishment, followed by pain. Because you find that the whole world is being recompiled and re linked!
When all this happens, are you just angry?
The reason for the problem is that C++ isnt doing very well in separating interfaces from implementation. In particular, the class definition of C++ contains not only interface specifications, but also many implementation details. Such as:
Class Person {
Public:
Person (const, string, name, const, Date, birthday),
Const, Address, addr, const, Country, country);
Virtual, ~Person ();
... / / simplicity, omit the copy constructor
/ / function and assignment operator function
String name () const;
String birthDate () const;
String address () const;
String nationality () const;
Private:
String name_; / / implementation details
date birthdate _; / / 实现细节
address address _; / / 实现细节
the country is _; / / 实现细节
};
这很难称得上是一个很高明的设计, 虽然它展示了一种很有趣的命名方式: 当私有数据和公有函数都想用某个名字来标识时, 让前者带一个尾部下划线就可以区别了.这里要注意到的重要一点是, person的实现用到了一些类, 即string, date, address和country; person要想被编译, 就得让编译器能够访问得到这些类的定义.这样的定义一般是通过 # include指令来提供的, 所以在定义person类的文件头部, 可以看到象下面这样的语句.
# include string / 用于string类型 (参见条款49)
# include date.h
# include address.h
# include country.h
遗憾的是, 这样一来, 定义person的文件和这些头文件之间就建立了编译依赖关系.所以如果任一个辅助类 (即string, date, address和country) 改变了它的实现, 或任一个辅助类所依赖的类改变了实现, 包含person类的文件以及任何使用了person类的文件就必须重新编译.对于person类的用户来说, 这实在是令人讨厌, 因为这种情况用户绝对是束手无策.
那么.
您可能关注的文档
- 期中复习(Midterm review).doc
- 期待可能性(Expectation possibility).doc
- 望闻问切断顽疾——中小企业主六大失败基因(Look, smell, ask, cut away chronic diseases -- six major failure genes of small and medium business owners).doc
- 期待可能性的机能扩张或紧缩(The function of anticipated possibilities expansion or contraction).doc
- 期货公司营业部经营现状(Operation status of Futures Company Sales Department).doc
- 期货交易金玉良言(Futures invaluable advice).doc
- 期货外汇日内炒单的超级技巧(含个人的小系统)(A super skill (including personal, small systems) for speculation on futures exchanges).doc
- 木业知识(Wood knowledge).doc
- 木丝水泥板、美岩水泥板施工方法详细介绍(The construction method of wood cement board, wood wool cement board is introduced in detail).doc
- 木乃伊王妃(Mummy Princess).doc
最近下载
- 征地拆迁工作总结.pptx VIP
- 二级公立医院绩效考核各指标最新的评分标准.pdf
- 辽宁省沈阳市和平区2023-2024学年五年级下学期期末数学试题.docx VIP
- 2025-2026年部编版五年级语文下册期末试卷及答案【完整】 .pdf VIP
- 艾克幕ICOM-IC-9700_维修说明书手册.pdf
- 湖南省普通高等学校招生体育类专业统一考试评分标准和考试细则(2023年版).pdf VIP
- 医院药品破损处理管理制度.docx VIP
- 钱江贝纳利前后减震加油量列表.xls VIP
- 7.1 血液 课件 2024-2025学年北师版生物七年级下册.pptx VIP
- 曲臂车培训课件.pptx VIP
文档评论(0)