- 1、本文档共33页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
华中科技大学博士论文答辩会-M.MuNeeBReHmaN
Pointers to Pointers C++ allows the use of pointers that point to pointers, that these, in its turn, point to data (or even to other pointers). char a; char *b; char **c; a = z; b = a; c = b; cout**c; Pointer to string constant Syntax: char * string Literal void main() { char str1[] = “Defined as an array”; char* str2 = “Defined as a pointer”; cout str1 endl; cout str2 endl; //str1++; // can’t do this; str1 is a constant str2++; // this is ok, str2 is a pointer cout str2 endl; // efined as a pointer } Pointer to string constant // Copying string using Pointers void main() { char* str1 = “Self-conquest is the greatest victory.”; char str2[80]; //empty string char* src = str1; char* dest = str2; while( *src ) //until null character, *dest++ = *src++; //copy chars from src to dest *dest = ‘\0’; //terminate dest cout str2 endl; //display str2 } Computer Programming Computer Programming Pointers Objectives To describe what a pointer is To learn how to declare a pointer and assign a value to it To access elements via pointers To pass arguments by reference with pointers To understand the relationship between arrays and pointers To know how to access array elements using pointers To declare constant pointers and constant data Introduction to Pointers Pointer variables, simply called pointers, are designed to hold memory addresses as their values Normally, a variable contains a specific value, e.g., an integer, a floating-point value, and a character However, a pointer contains the memory address of a variable that in turn contains a specific value Introducing Pointers When we declare a variable, some memory is allocated for it. Thus, we have two properties for any variable: Its Address and Its Data value For Example, int count = 5; Introducing Pointers How to get the memory-address of a variable? Address of a variable can be accessed thr
您可能关注的文档
- 北京师范大学珠海分校公共体育课程-运动休闲学院.doc
- 北京理工大学软件学院.doc
- 北京石油化工学院.doc
- 北京科技大学.ppt
- 北京电子科技职业学院简介-高职教育技术网.ppt
- 北欧城市规划及生态建筑考察.doc
- 区四套班子领导务虚会初步方案.doc
- 北京师范大学图书馆服务外包探索与实践王琪.ppt
- 北京四中网校合作学校教师版规划书.doc
- 北欧设计.ppt
- 福莱特玻璃集团股份有限公司海外监管公告 - 福莱特玻璃集团股份有限公司2024年度环境、社会及管治报告.pdf
- 广哈通信:2024年度环境、社会及治理(ESG)报告.pdf
- 招商证券股份有限公司招商证券2024年度环境、社会及管治报告.pdf
- 宏信建设发展有限公司2024 可持续发展暨环境、社会及管治(ESG)报告.pdf
- 品创控股有限公司环境、社会及管治报告 2024.pdf
- 中信建投证券股份有限公司2024可持续发展暨环境、社会及管治报告.pdf
- 洛阳栾川钼业集团股份有限公司环境、社会及管治报告.pdf
- 361度国际有限公司二零二四年环境、社会及管治报告.pdf
- 中国神华能源股份有限公司2024年度环境、社会及管治报告.pdf
- 广西能源:2024年环境、社会及治理(ESG)报告.pdf
文档评论(0)