- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 19Vectors, templates, and exceptions.ppt
String A string is rather similar to a vectorchar E.g. size(), [ ], push_back() Built with the same language features and techniques A string is optimized for character string manipulation Concatenation (+) Can produce C-style string (c_str()) input terminated by whitespace * 6 H o w y d ! Stroustrup/Programming \0 Next lecture An introduction to the STL, the containers and algorithms part of the C++ standard library. Here we’ll meet sequences, iterators, and containers (such as vector, list, and map). The algorithms include find(), find_if(), sort(), copy(), copy_if(), and accumulate(). * Stroustrup/Programming Chapter 19Vectors, templates, and exceptions Bjarne Stroustrup /Programming Abstract This is the third of the lectures exploring the design of the standard library vector and the techniques and language features used to implement it. Here, we deal with changing the size of a vector, parameter-ization of a vector with an element type (templates), and range checking (exceptions). * Stroustrup/Programming Overview Vector revisited How are they implemented? Pointers and free store Destructors Copy constructor and copy assignment Arrays Array and pointer problems Changing size resize() and push_back() Templates Range checking and exceptions * Stroustrup/Programming Changing vector size Fundamental problem addressed We (humans) want abstractions that can change size (e.g., a vector where we can change the number of elements). However, in computer memory everything must have a fixed size, so how do we create the illusion of change? Given vector v(n); // v.size()==n we can change its size in three ways Resize it v.resize(10); // v now has 10 elements Add an element v.push_back(7); // add an element with the value 7 to the end of v // v.size() increases by 1 Assign to it v = v2; // v is now a copy of v2 // v.size() now equals v2.size() * Stroustrup/Programming Representing vector If you resize() or push_back() once, you’ll probably do it again; let
您可能关注的文档
- Assignment PresentationWednesday 17 February 2010.ppt
- AST Introduction.ppt
- ASTHO Healthy Babies Challenge.ppt
- Astrofotografie 1.ppt
- ATACCCSt. Petersburg, FLAugust 17, 2003.ppt
- Audit Responsibilitiesand Objectives.ppt
- Aug.19, 1999.ppt
- August 19, 2002Hong Kong.ppt
- Authorship Analysis in Cybercrime Investigation.PPT
- Band Gaps GW Quasiparticle Results vs Experiment.ppt
- Chapter 1Assuming the Role of the Systems Analyst.ppt
- Chapter 1INTRODUCTION TO OPERATIONS MANAGEMENT.ppt
- Chapter 1Software and SoftwareEngineering.ppt
- Chapter 2 Excitation and Conductio of nervous.ppt
- Chapter 2. Customers, Products, and OM Strategy.ppt
- Chapter 27.ppt
- Chapter 28Medical Office.ppt
- Chapter 3 Combination and Sequential Circuits Modeling.ppt
- Chapter 3Structure and Stereochemistryof Alkanes.ppt
- Chapter 4 Ship's Structure and Equipment.ppt
最近下载
- 2024年上海闵行区初三二模中考数学试卷试题(含答案详解) .pdf VIP
- 道德与法治五年级上册统编版《开学第一课》课件.pptx VIP
- ZZ027 全国职业院校技能大赛(中职组) 婴幼儿保育赛项理论题第7套(含答案).doc VIP
- 井下作业操作手册(防砂作业).pdf VIP
- ZZ027 全国职业院校技能大赛(中职组) 婴幼儿保育赛项理论题第10套(含答案).doc VIP
- 主题教育反面典型案例交流材料.pdf VIP
- YD_T 1051-2018 通信局(站)电源系统总技术要求.docx VIP
- 贝克完井工具介绍.pdf VIP
- 新人教版,四年级数学上册全册教案(含设计意图)及教学反思.pdf VIP
- 学生档案信息登记表.docx VIP
文档评论(0)