- 1、本文档共22页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
More on Operator Overloading - Worcester Polytechnic Institute 对运算符重载-伍斯特理工学院.ppt
CS-2303, C-Term 2010 More on Operator Overloading More on Operator Overloading CS-2303System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan and Ritchie, from C: How to Program, 5th and 6th editions, by Deitel and Deitel, and from The C++ Programming Language, 3rd edition, by Bjarne Stroustrup) Case Study — Array Class Problems with pointer-based arrays in C++:– No range checking. Cannot be compared meaningfully with == No array assignment (array names are const pointers). If array passed to a function, size must be passed as a separate argument. Can we do better? I.e., can we create a data type that looks like an array but has the missing properties Point of Operator Overloading By using C++ classes and operator overloading, … … one can significantly change the capabilities of a built-in type In this case, of the built-in array type Case Study — Array Class Implement an Array class with:– Range checking Array assignment ( = ) Arrays that know their own size. Array comparisons with == and != Output/input of entire arrays with and Array Class Copy Constructor Used whenever copy of object is needed: Passing by value (return value or parameter). Initializing an object with a copy of another of same type. Array newArray( oldArray ); or Array newArray = oldArray; Both are identical newArray is a copy of oldArray. Definition – Copy Constructor A constructor of some type T of the form T (const T); The single argument must be a const reference to an existing object of same type Creates a duplicate of the existing object Used whenever a copy of an object is needed Including arguments to functions, results returned from functions Array Class Definition Array Class Definition Array Class Definition (continued) Array Class Implementation Array Class Implementation (continued) Array Class Implementation (continued) Array Class Implementation (continued) Array Class Implementation (continued) Array Class I
您可能关注的文档
- 第三讲 财务分析与业绩评价[突破高绩效管理].ppt
- 网络游戏在高校教育中的价值 - 中国教育游戏研究网.ppt
- 2012届高考语文二轮复习精品课件(湖南专用)第5课时 文言断句.ppt
- 2012届高考语文二轮复习精品课件(湖南专用)第7课时 散文类阅读.ppt
- 英语:unit3 life in the future-reading课件(新人教版必修5).ppt
- Representation of Numbers表示数字的.ppt
- 《教学系统设计》第一章概述.ppt
- 高一unit 7 warming up课件.ppt
- 高中数学必修一二次方程根的分布问题.ppt
- 439W –Writing Topic #3439w–写作话题# 3.ppt
- 2025年押题宝典演出经纪人之《演出经纪实务》题库附完整答案详解【精选题】.docx
- 2025年押题宝典演出经纪人之《演出市场政策与法律法规》题库及完整答案详解(考点梳理).docx
- 2025年湖南省初中学业水平考试仿真密卷-道德与法治(B卷).pptx
- 第3章 一次方程(组) 综合素质评价(含答案)2025-2026学年湘教版数学七年级上册.docx
- 2025年湖南省初中学业水平考试仿真密卷-英 语(B卷).pptx
- DB11_T1293.4-2015_卫生应急最小工作单元装备技术要求第4部分:核与辐射事故处置类_北京市.pdf
- DB11_T1322.68-2019_安全生产等级评定技术规范第68部分:设施蔬菜生产企业及专业合作社_北京市.pdf
- DB11_T1322.71-2018_安全生产等级评定技术规范第71部分:社会福利机构_北京市.pdf
- DB11_T1313-2015_薄抹灰外墙外保温用聚合物水泥砂浆应用技术规程_北京市.pdf
- DB11_T1320-2023_危险场所电气防爆安全检测技术规范_北京市.pdf
文档评论(0)