C++ Primer Plus 第6版 - 笔记

基本信息

  • 书名: C++ Primer Plus
  • 版本: Sixth Edition (第6版)
  • 作者: Stephen Prata
  • 出版社: Addison-Wesley (Developer’s Library系列)
  • 出版年: 2012
  • 页数: 1438页
  • 语言: 英文
  • ISBN: 978-0-321-77640-2

书籍定位

这是C++编程领域的经典入门教材,属于”Developer’s Library”系列,该系列定位为”为编程专业人士提供高质量参考和教程”。本书以循序渐进的方式介绍C++编程,适合初学者和有一定经验的程序员。

内容结构

第1-2章:C++入门

  • 第1章 Getting Started with C++: C++历史、可移植性与标准、创建程序的机制
  • 第2章 Setting Out to C++: C++语句、变量、const限定符、浮点数、算术运算符

第3-4章:数据类型

  • 第3章 Dealing with Data: 简单数据模型、字符类型、宽字符、字符串字面量、C++字符串类
  • 第4章 Compound Types: 数组、C风格字符串、string类、结构体、联合体、枚举、指针

第5-6章:流程控制

  • 第5章 Loops and Relational Expressions: for循环、while循环、do while循环、基于范围的for循环(C++11)、嵌套循环
  • 第6章 Branching Statements and Logical Operators: if语句、逻辑表达式、switch语句、条件运算符

第7-8章:函数

  • 第7章 Functions: C++‘s Programming Modules: 函数基础、函数参数、数组与函数、递归、指针到函数
  • 第8章 Adventures in Functions: inline函数、引用变量、默认参数、函数重载、函数模板

第9章:内存模型与命名空间

  • Separate Compilation(分离编译)
  • Storage Duration, Scope, and Linkage(存储期、作用域和链接性)
  • Namespaces(命名空间)

第10-12章:面向对象编程

  • 第10章 Objects and Classes: 过程和面向对象编程、抽象与类、构造函数和析构函数、this指针
  • 第11章 Working with Classes: 运算符重载、友元、自动转换与类型转换
  • 第12章 Classes and Dynamic Memory Allocation: new/delete、string类改进、动态内存管理

第13-14章:继承与代码复用

  • 第13章 Class Inheritance: 基类、is-a关系、多态公有继承、静态与动态绑定、protected访问控制、抽象基类
  • 第14章 Reusing Code in C++: 类与对象成员、私有继承、多重继承、类模板

第15章:高级特性

  • Friends、Nested Classes、Exceptions、Runtime Type Identification、Type Cast Operators

第16章:STL

  • string类深入
  • Smart Pointer Template Classes
  • The Standard Template Library (STL)
  • Generic Programming(泛型编程)
  • Function Objects (Functors)
  • Algorithms

第17-18章:输入输出与现代C++

  • 第17章 Input, Output, and Files: cout/cin、文件输入输出、格式化
  • 第18章 Visiting with the New C++ Standard: C++11特性回顾、移动语义、Lambda函数、Wrappers、Variadic Templates

附录

  • A: Number Bases
  • B: C++ Reserved Words
  • C: The ASCII Character Set
  • D: Operator Precedence
  • E: Other Operators
  • F: The string Template Class
  • G: The Standard Template Library Methods and Functions
  • H: Selected Readings and Internet Resources
  • I: Converting to ISO Standard C++
  • J: Answers to Chapter Reviews

核心知识点

1. C++特性概览

  • 面向对象: 封装、继承、多态
  • 泛型编程: 模板、STL
  • 异常处理: try-catch机制
  • RAII: 资源获取即初始化模式

2. 内存管理

  • 栈内存 vs 堆内存
  • new/delete操作符
  • 智能指针(第16章引入)
  • 移动语义(C++11)

3. STL核心组件

  • 容器: vector, list, map, set等
  • 迭代器: 统一访问容器元素
  • 算法: sort, find, copy等通用算法
  • 函数对象: 可调用对象

4. C++11新特性

  • 基于范围的for循环
  • auto类型推导
  • nullptr
  • Lambda表达式
  • 移动语义和右值引用
  • 变长参数模板

学习建议

  1. 循序渐进: 按照章节顺序学习,不要跳过基础概念
  2. 动手实践: 每章都有编程练习,务必完成
  3. 理解内存模型: 第9章的内存模型是理解C++的关键
  4. 掌握STL: 第16章的STL是C++编程的核心工具
  5. 关注C++11: 第18章介绍的现代C++特性在实际开发中非常重要

与其他资源的关联