没有合适的资源?快使用搜索试试~ 我知道了~
首页C++ Primer 4th Edition: 现代编程风格指南(英文PDF,基于CHM版制作)
"C++ Primer 4th Edition 是一本由作者亲自根据CHM版本制作的英文清晰PDF,旨在提供全面的C++语言入门教程,同时深入探讨现代编程技术和C++标准库的使用。"
《C++ Primer》第四版是C++初学者的权威指南,它以清晰的教程方式介绍C++语言,配以丰富的示例和学习辅助材料。与其他入门书籍不同,这本书不仅教授基础,还详尽地介绍了当前和有效的编程技术。多年来,无数程序员通过前几版的《C++ Primer》学会了C++,随着语言的发展,C++程序员的关注点已经从运行时效率转向提高程序员自身的效率。
C++的标准库现在被广泛使用,使得学习和使用C++变得更加高效。第四版的修订正是基于这些新的可能性,完全重新组织和编写了内容,以突出现代C++编程风格。本书的核心是利用标准库,而降低了对底层技术的强调。
在第四版中的主要变化包括:
1. 强调标准库:新版教程将使用标准库置于中心位置,因为标准库是现代C++编程的关键部分,它提供了大量的容器、算法和工具,能帮助程序员更高效地编写代码。
2. 现代编程风格:更新的内容反映了C++语言的最新发展,包括智能指针、RAII(Resource Acquisition Is Initialization)、模板元编程、Lambda表达式等现代特性,这些都大大提高了代码的可读性和维护性。
3. 效率与设计:本书更加注重代码的设计和可维护性,而非仅仅追求运行时效率。这包括了对现代C++设计模式的介绍,如面向对象编程、泛型编程和函数式编程的融合。
4. 实践应用:除了理论讲解,书中包含了大量的练习题和实例,鼓励读者动手实践,以巩固学习的知识,并提升解决问题的能力。
5. 改进的结构:为了更好地引导读者学习,书中的章节顺序和内容布局进行了优化,确保概念的逐步展开和逻辑的连贯性。
《C++ Primer》第四版是一本全面而现代的C++学习资料,无论是对于初次接触C++的初学者,还是寻求提升编程技能的有经验开发者,都能从中获益。通过阅读这本书,读者不仅可以掌握C++的基础知识,还能了解到如何利用C++的标准库和最佳实践来编写高效、可维护的代码。
Exercises Section 15.2.3 .......................................................................................................802
Key Concept: Polymorphism in C++....................................................................................805
Exercises Section 15.2.4 .......................................................................................................808
Key Concept: Inheritance versus Composition.....................................................................812
Exercises Section 15.2.5 .......................................................................................................815
Exercises Section 15.2.7 .......................................................................................................817
15.3. Conversions and Inheritance................................................................................818
15.4. Constructors and Copy Control............................................................................822
Key Concept: Refactoring.....................................................................................................826
Key Concept: Respecting the Base-Class Interface..............................................................828
Exercises Section 15.4.2 .......................................................................................................828
Exercises Section 15.4.4 .......................................................................................................834
15.5. Class Scope under Inheritance .............................................................................836
Exercises Section 15.5.1 .......................................................................................................837
Exercises Section 15.5.2 .......................................................................................................839
Key Concept: Name Lookup and Inheritance ..............................................................843
Exercises Section 15.5.4 ..............................................................................................843
15.6. Pure Virtual Functions..........................................................................................844
Exercises Section 15.6 ..........................................................................................................845
15.7. Containers and Inheritance...................................................................................846
Exercises Section 15.7 ..........................................................................................................847
15.8. Handle Classes and Inheritance............................................................................848
Exercises Section 15.8.2 .......................................................................................................854
Exercises Section 15.8.3 .......................................................................................................859
15.9. Text Queries Revisited .........................................................................................860
Exercises Section 15.9.2 .......................................................................................................866
Exercises Section 15.9.5 .......................................................................................................875
Exercises Section 15.9.6 .......................................................................................................878
Chapter Summary .........................................................................................................878
Defined Terms...............................................................................................................879
Chapter 16. Templates and Generic Programming ....................................................883
16.1. Template Definitions............................................................................................883
Exercises Section 16.1.1 .......................................................................................................887
Exercises Section 16.1.2 .......................................................................................................889
Exercises Section 16.1.3 .......................................................................................................892
Exercises Section 16.1.4 .......................................................................................................895
Exercises Section 16.1.5 .......................................................................................................897
Exercises Section 16.1.6 .......................................................................................................899
Caution: Compile-Time Errors at Link-Time........................................................................900
16.2. Instantiation..........................................................................................................900
Exercises Section 16.2.1 .......................................................................................................908
Exercises Section 16.2.2 ..............................................................................................912
16.3. Template Compilation Models.............................................................................913
Exercises Section 16.3 ..........................................................................................................916
Caution: Name Lookup in Class Templates..........................................................................916
16.4. Class Template Members .....................................................................................917
Exercises Section 16.4 ..........................................................................................................921
Exercises Section 16.4.1 .......................................................................................................927
Exercises Section 16.4.2 .......................................................................................................928
Exercises Section 16.4.4 .......................................................................................................935
Exercises Section 16.4.6 .......................................................................................................942
16.5. A Generic Handle Class .......................................................................................944
Exercises Section 16.5.1 .......................................................................................................947
Exercises Section 16.5.2 .......................................................................................................950
16.6. Template Specializations......................................................................................950
Exercises Section 16.6.1 .......................................................................................................955
Exercises Section 16.6.2 .......................................................................................................957
Exercises Section 16.6.3 .......................................................................................................959
16.7. Overloading and Function Templates...................................................................962
Exercises Section 16.7 ..........................................................................................................965
Chapter Summary .........................................................................................................966
Defined Terms...............................................................................................................967
Part V: Advanced Topics...............................................................................................................971
Chapter 17. Tools for Large Programs ......................................................................973
17.1. Exception Handling..............................................................................................973
Exercises Section 17.1.1 .......................................................................................................977
Exercises Section 17.1.3 .......................................................................................................983
Exercises Section 17.1.5 .......................................................................................................986
Exercises Section 17.1.8 .......................................................................................................993
Exercises Section 17.1.9 .....................................................................................................1000
Caution: Auto_ptr Pitfalls ...................................................................................................1001
警告:Auto_ptr 缺陷 ........................................................................................................1001
Exercises Section 17.1.11....................................................................................................1008
17.2. Namespaces ....................................................................................................1008
Exercises Section 17.2.1 ............................................................................................1015
Exercises Section 17.2.2 ............................................................................................1017
Unnamed Namespaces Replace File Statics ..............................................................1019
Exercises Section 17.2.3 ............................................................................................1020
Exercises Section 17.2.4 ............................................................................................1025
Caution: Avoid Using Directives ..............................................................................1026
Exercises Section 17.2.6 ............................................................................................1034
17.3. Multiple and Virtual Inheritance ........................................................1035
Exercises Section 17.3.1 ............................................................................................1038
Exercises Section 17.3.2 ............................................................................................1040
Exercises Section 17.3.2 ............................................................................................1043
Code for Exercises to Section 17.3.4 ....................................................................1046
Exercises Section 17.3.4 ............................................................................................1047
Exercises Section 17.3.6 ............................................................................................1053
Exercises Section 17.3.7 ............................................................................................1057
Chapter Summary .......................................................................................................1058
Defined Terms.............................................................................................................1059
Chapter 18. Specialized Tools and Techniques ....................................................1065
18.1. Optimizing Memory Allocation ................................................................1065
Exercises Section 18.1.2 ............................................................................................1072
Terminology: new Expression versus operator new Function ............................1073
Exercises Section 18.1.4 ............................................................................................1076
Exercises Section 18.1.5 ............................................................................................1077
Exercises Section 18.1.6 ............................................................................................1080
Exercises Section 18.1.7 ............................................................................................1088
18.2. Run-Time Type Identification ................................................................1089
Exercises Section 18.2.1 ............................................................................................1092
Exercises Section 18.2.2 ............................................................................................1095
Exercises Section 18.2.4 ............................................................................................1100
18.3. Pointer to Class Member ..........................................................................1101
Exercises Section 18.3.1 ............................................................................................1104
Exercises Section 18.3.2 ............................................................................................1108
18.4. Nested Classes ............................................................................................1109
Exercises Section 18.4.2 ............................................................................................1116
18.5. Union: A Space-Saving Class ..................................................................1116
18.6. Local Classes ..............................................................................................1120
18.7. Inherently Nonportable Features ..........................................................1123
Preprocessor Support for Linking to C ..................................................................1130
Exercises Section 18.7.3 ............................................................................................1132
Chapter Summary .......................................................................................................1133
Defined Terms ..........................................................................................................1134
Appendix A. The Library ......................................................................................................1139
A.1. Library Names and Headers........................................................................................1140
Table A.1. Standard Library Names and Headers .......................................................1140
A.2. A Brief Tour of the Algorithms ......................................................................1143
A.2.1. Algorithms to Find an Object ..............................................................1143
A.2.2. Other Read-Only Algorithms ..................................................................1145
A.2.3. Binary-Search Algorithms ......................................................................1146
A.2.4. Algorithms that Write Container Elements ......................................1147
A.2.5. Partitioning and Sorting Algorithms ................................................1150
A.2.6. General Reordering Operations ............................................................1152
A.2.7. Permutation Algorithms ..........................................................................1155
A.2.8. Set Algorithms for Sorted Sequences ................................................1156
A.2.9. Minimum and Maximum Values ..................................................................1157
A.2.10. Numeric Algorithms ................................................................................1158
A.3. The IO Library Revisited ..................................................................................1161
A.3.1. Format State ..............................................................................................1161
A.3.2. Many Manipulators Change the Format State ....................................1162
A.3.3. Controlling Output Formats ..................................................................1164
A.3.4. Controlling Input Formatting ..............................................................1171
A.3.5. Unformatted Input/Output Operations ................................................1172
A.3.6. Single-Byte Operations ..........................................................................1172
A.3.7. Multi-Byte Operations ............................................................................1174
Caution: Low-Level Routines Are Error-Prone ......................................................1175
A.3.8. Random Access to a Stream ....................................................................1177
A.3.9. Reading and Writing to the Same File ..............................................1180
Chapter 1. Getting Started
This chapter introduces most of the basic elements of C++: built-in,
library, and class types; variables; expressions; statements; and
functions. Along the way, we'll briefly explain how to compile and execute
a program.
Having read this chapter and worked through the exercises, the reader
should be able to write, compile, and execute simple programs. Subsequent
chapters will explain in more detail the topics introduced here.
Learning a new programming language requires writing programs. In this
chapter, we'll write a program to solve a simple problem that represents
a common data-processing task: A bookstore keeps a file of transactions,
each of which records the sale of a given book. Each transaction contains
an ISBN (International Standard Book Number, a unique identifier assigned
to most books published throughout the world), the number of copies sold,
and the price at which each copy was sold. Each transaction looks like
0-201-70353-X 4 24.99
where the first element is the ISBN, the second is the number of books
sold, and the last is the sales price. Periodically the bookstore owner
reads this file and computes the number of copies of each title sold, the
total revenue from that book, and the average sales price. We want to
supply a program do these computations.
Before we can write this program we need to know some basic features
of C++. At a minimum we'll need to know how to write, compile, and execute
a simple program. What must this program do? Although we have not yet
designed our solution, we know that the program must
• Define variables
• Do input and output
• Define a data structure to hold the data we're managing
• Test whether two records have the same ISBN
• Write a loop that will process every record in the transaction file
We'll start by reviewing these parts of C++ and then write a solution
to our bookstore problem.
1.1. Writing a Simple C++ Program
剩余1182页未读,继续阅读
2018-11-21 上传
535 浏览量
2010-04-11 上传
2020-10-27 上传
jenf
- 粉丝: 10
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Python和Opencv的车牌识别系统实现
- 我的代码小部件库:统计、MySQL操作与树结构功能
- React初学者入门指南:快速构建并部署你的第一个应用
- Oddish:夜潜CSGO皮肤,智能爬虫技术解析
- 利用REST HaProxy实现haproxy.cfg配置的HTTP接口化
- LeetCode用例构造实践:CMake和GoogleTest的应用
- 快速搭建vulhub靶场:简化docker-compose与vulhub-master下载
- 天秤座术语表:glossariolibras项目安装与使用指南
- 从Vercel到Firebase的全栈Amazon克隆项目指南
- ANU PK大楼Studio 1的3D声效和Ambisonic技术体验
- C#实现的鼠标事件功能演示
- 掌握DP-10:LeetCode超级掉蛋与爆破气球
- C与SDL开发的游戏如何编译至WebAssembly平台
- CastorDOC开源应用程序:文档管理功能与Alfresco集成
- LeetCode用例构造与计算机科学基础:数据结构与设计模式
- 通过travis-nightly-builder实现自动化API与Rake任务构建
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功