- 1
- 0
- 约9.28千字
- 约 31页
- 2021-11-30 发布于安徽
- 举报
Customized Function Objects By defining member function operator() in a class * class My { public: int operator()(int a) {return a;} } ; My mo; int x = mo(0); template typename T class greater : binary_function T,T,bool { public: bool operator() (const T x, const T y) const{return xy;} }; class BiggerThan{ public: const int testValue; BiggerThan(int x) : testValue(x) { } bool operator()(int val) const { return val testValue; } }; int my[] = {1, 7, 3, 4, 3, 3, 1, 2}; sort(my, my + 8, Mygreaterint()); BiggerThan bt(10); coutbt(11) bt(9)endl; My m; coutm(4)endl; 1 0 4 A Summary Concepts STL, Container, Iterator, Algorithm Three types of containers Function, Operation, Algorithm Functional object Features of different containers Main functions of containers Features of STL algorithm Use of functional object * Chapter 14 Introduction to the Standard Template Library §14.1 Introduction §14.2 Containers §14.3 Iterators §14.4 Algorithms §14.5 Function Objects §14.1 Introduction Standard Template Library (STL) 标准模板库 A software library included in the C++ Standard Library Purpose To standardize commonly used components History Originally developed by Alexander Stepanov in 1980s Accepted as part of C++ standard in Feb. 1994 * Components of STL Containers(容器) A container object, such as vector, used to store a collection of data, often referred to as elements Algorithms(算法) Functions to manipulate data such as sorting, searching, and comparing elements. Most of them use iterators to access the elements in the container. Iterators(迭代器) Objects that facilitate traversing through the elements in a container Like built-in pointers that provide a convenient way to access and manipulate the elements in a container * Components of STL * Algorithm 3 Algorithm 2 Algorithm 1 Container Object 1 Object 2 Object 3 Iterator 3 Iterator 2 Iterator 1 §14.2 Containers * Containers vector deque list Sequence containers set
您可能关注的文档
- 高等数学课件:9-5 二阶线性常系数微分方程.ppt
- 高等数学课件:9-7常系数线性微分方程组.ppt
- 高等数学课件:10.1向量及其运算(1-30).ppt
- 高等数学课件:10.2 空间直角坐标系与向量代数(1-24).ppt
- 高等数学课件:10.3 平面与直线.ppt
- 高等数学课件:10.4.1曲面及其方程.ppt
- 高等数学课件:10.4.2二次曲面.ppt
- 高等数学课件:10.5向量函数 空间曲线.ppt
- 高等数学课件:10-1 收敛原理与数项级数.ppt
- 高等数学课件:10-2 正项级数.ppt
- 软件设计(II)教学课件:Chapter1-4 Basics of OOP and C++.ppt
- 软件设计(II)教学课件:Chapter5 Classes and Objects.ppt
- 软件设计(II)教学课件:Chapter6 Constructors and Destructors.ppt
- 软件设计(II)教学课件:Chapter7 Operator Overloading and Type Conversions.ppt
- 软件设计(II)教学课件:Chapter8 Inheritance.ppt
- 软件设计(II)教学课件:Chapter9 Pointers, Virtual Functions and Polymorphism.ppt
- 软件设计(II)教学课件:Chapter10 Console IO Operations.ppt
- 软件设计(II)教学课件:Chapter11 Working with Files.ppt
- 软件设计(II)教学课件:Chapter12 Templates(模板).ppt
- 软件设计(II)教学课件:Chapter13 Exception Handling.ppt
最近下载
- 江苏省兴化市2025年上半年公开招聘村务工作者试题含答案分析.docx VIP
- XX实验学校九年级英语备课组长在2026年春季学期中考题型专项复习计划解读.docx VIP
- 2026年树立和践行正确政绩观学习教育专题读书班方案(含:详细日程表)文稿供借鉴.docx VIP
- (正式版)DB12∕T 1339-2024 《城镇社区公共服务设施规划设计指南》.docx VIP
- 组织设计与工作分析教学课件8.pptx VIP
- 河海大学2020-2021学年《财务管理学》期末考试试卷(B卷)含参考答案.docx
- 急诊科护理知识考试试题(含答案).docx VIP
- 第6课+欧洲的思想解放运动【中职专用】《世界历史》(高教版2023基础模块).pptx VIP
- 职业院校教学质量管理监测评价指标体系.doc VIP
- CECS19-1990 混凝土排水管道工程闭气检验标准.docx VIP
原创力文档

文档评论(0)