- 1、本文档共56页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
数据结构与程序设计教师鲍钰
数据结构与程序设计 教师:鲍钰 数据结构与程序设计(7) 教师:鲍钰 ybao@sei.ecnu.edu.cn 第四章 Linked Stacks and Queues 问题的提出 P113 引入指针 Figure 4.1 指针声明 C++ uses an asterisk * to denote a pointer. If Item is a type, then a pointer to such an Item object has the type Item *. For example, Item *item_ptr; declares item_ptr as a pointer variable to an Item object. Creating dynamic objects Item_ptr = new Item; creates a new dynamic object of type Item and assigns its location to the pointer variable item_ptr. Deleting dynamic objects delete item_ptr; disposes of the dynamic object to which item_ptr points and returns the space it occupies to the free store so it can be used again. Following pointers *item_ptr denotes the object to which item_ptr points. NULL pointers If a pointer variable item_ptr has no dynamic object to which it currently refers, then it should be given the special value. Item_ptr = NULL; Uninitialized or random pointer objects should always be reset to NULL. After deletion, a pointer object should be reset to NULL. #includeiostream.h Dynamically Allocated Arrays Item_array = new Item[array_size]; creates a dynamic array of Item objects, indexed from 0 up to array_size ? 1. Dynamically Allocated Arrays for example: int size, *dynamic_array, i; cout Enter an array size: ; cin size; dynamic_array = new int[size]; for (i = 0; i size; i++) dynamic_array[i] = i; Dynamically Allocated Arrays Dynamically Allocated ArraysP120 Dynamically Allocated Arrays delete [] dynamic_array; returns the storage in dynamic array to the free store. 指针运算 If i is an integer value and p is a pointer to an Item, then p + i is an expression of type Item *. The value of p + i gives the memory address offset from p by i Item objects. That is, the expression p + i actually yields the address p + n*i, where n is the number of bytes of storage occupied by a simple object of type Item. Addresses of automatic objects If x is a variable of type Item, then x is a value of type Item * that gives the ad
您可能关注的文档
- 情境教学法在小学英语在教学中的运用.doc
- 惠州星河丹堤 俯瞰天下万家灯火 !华南师大附中 成就未来!!.ppt
- 意_陈其宽90展览.pptx
- 惠东项目ACDK介绍.ppt
- 意维丝铜线资料.pdf
- 感受国际贸易 那些记忆中的中国名牌.ppt
- 意大利非凡电池技术交流以及培训讲义.ppt
- 感叹地球之美.ppt
- 意大利肉酱面.ppt
- 感恩教育之我见1.doc
- 《我国金融市场波动率预测模型比较:基于主成分分析的多模型预测方法》教学研究课题报告.docx
- 《固体废弃物分类回收政策对产业结构调整的影响分析》教学研究课题报告.docx
- 小学美术课程“设计·应用”领域教学资源的开发与利用研究教学研究课题报告.docx
- 初中物理实验创新教学中的实验设计与实施案例分析教学研究课题报告.docx
- 地铁工程监理质量评估报告.doc
- 教育机构股东合同.doc
- 智能教育平台在融合教育中特殊学生情感教育的应用研究教学研究课题报告.docx
- 智慧校园背景下小学语文教学管理的优化策略探讨教学研究课题报告.docx
- 《老年痴呆患者非药物干预措施在护理过程中的实施策略研究》教学研究课题报告.docx
- 初中生出行便利性提升:校园周边公交站点布局与周边环境协调发展探讨教学研究课题报告.docx
文档评论(0)