- 1、本文档共83页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
6 数据类型
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1-* Pointers in C and C++ Extremely flexible but must be used with care Pointers can point at any variable regardless of when or where it was allocated Used for dynamic storage management and addressing Pointer arithmetic (指针算数) is possible Explicit dereferencing and address-of operators Domain type need not be fixed (void *) void * can point to any type and can be type checked (cannot be de-referenced) 1-* Pointer Arithmetic in C and C++ float stuff[100]; float *p; p = stuff; *(p+5) is equivalent to stuff[5] and p[5] *(p+i) is equivalent to stuff[i] and p[i] 1-* Reference Types C++ includes a special kind of pointer type called a reference type that is used primarily for formal parameters Advantages of both pass-by-reference and pass-by-value Java extends C++’s reference variables and allows them to replace pointers entirely References are references to objects, rather than being addresses C# includes both the references of Java and the pointers of C++ 1-* Evaluation of Pointers Dangling pointers and dangling objects are problems as is heap management Pointers are like gotos--they widen the range of cells that can be accessed by a variable Pointers or references are necessary for dynamic data structures--so we cant design a language without them 1-* Representations of Pointers Large computers use single values Intel microprocessors use segment and offset 1-* Dangling Pointer Problem Tombstone: extra heap cell that is a pointer to the heap-dynamic variable The actual pointer variable points only at tombstones When heap-dynamic variable de-allocated, tombstone remains but set to nil Costly in time and space . Locks-and-keys: Pointer values are represented as (key, address) pairs Heap-dynamic variables are represented as variable plus cell for integer lock value When heap-dynamic variable allocated, lock value is created and pl
您可能关注的文档
- 风光能源电气控制.ppt
- Access报表制作数据访问页.ppt
- 4.1血型.ppt
- chap多媒体数据压缩技术.ppt
- CHAP关系数据库模型.ppt
- chap数据库设计.ppt
- CHed数据链路层.ppt
- CNKI与VIP数据库谢昆.ppt
- C语言中的数据对齐问题.doc
- C语言第章利用数组处理批量数据.doc
- springbooot+vue基于java的房屋维修系统毕业论文.doc
- 中国消防救援学院《单片机系统实验》2023-2024学年第一学期期末试卷.doc
- 2025年溧阳纺织化学品项目申请.pptx
- 景区门票包销合同模板(3篇).docx
- 【股票技术指标学习指南】第七章第三节货币需要量的测算.doc
- 2025春 _ 人教版七年级英语下册【unit4】看音标写单词.doc
- 2025春 _ 人教版七年级英语下册【unit5】看音标写单词.doc
- 2025春 _ 人教版七年级英语下册【unit6】看音标写单词.doc
- 2025春 _ 人教版七年级英语下册【unit7】看音标写单词.doc
- 2025春 _ 人教版七年级英语下册【unit8】看音标写单词.doc
最近下载
- 敬老院运营与管理规范.docx VIP
- DB31_T 1598-2025 __城市轨道交通车辆寿命评估通用要求.pdf
- 分户验收方案 .doc VIP
- 液力變矩器的结构.doc VIP
- 2025年内蒙古自治区公安机关留置看护监管机构(专业知识)考试试题【含答案】.pdf VIP
- 一汽-大众-迈腾MAGOTAN-产品使用说明书-新一代迈腾330TSI DSG尊贵型-FV7187BBDBG-MagotanB8L-201606.pdf
- 液态氢风险分析.docx VIP
- TCAAA051-2020湖羊规范合格.pdf VIP
- 地震救援 地震八大救援知识 .docx VIP
- 牛根生致中国企业家俱乐部理事及长江商学院同学的一封信Microsoft Word.doc VIP
文档评论(0)