参考书籍: C++程序设计教程_第二版_钱能 // 篇辐较少, 讲得基本到位, 快速学习的话建议看它 C++ Primer Plus 第6版 中文版 // 篇辐较大, 讲得非常细, 有很多时间、想掌握更多更细, 看它 一. 类的引入 C语言是面向过程的 出一道题:写一个程序,输出张三、李四两个人的姓名、年龄 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v1 // 01th_oop 二. c++基础知识 1. 访问控制, 类和对象 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v2 // 02th_accesscontrol 2. 程序结构 (Program Structure) 2.1 类定义(.h)/类实现(.cpp) 2.2 命名空间 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v3 // 03th_ProgramStructure 3. 重载 指针和引用 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v4 // 04th_overload git checkout v5 // 05th_pointer_reference 4. 构造函数 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v6 // 06th_constructor 5. 静态成员 友员函数 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v7 // 07th_static git checkout v8 // 08th_friend 6. 再论重载: 操作符重载 int a = 1; int b = 2; int c = a + b; Point p1, p2; Point p3 = p1+p2; 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v9 // 09th_operator 三. 继承 1. 继承与访问控制 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v10 // 10th_inheritance 2. 多重继承 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v11 // 11th_multi_inheritance 3. 构造顺序 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v12 // 12th_constructor_2 四. 多态(Polymorphism) 1. 多态 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v13 // 13th_Polymorphism 2. 类型转换 好文 http://www.cnblogs.com/chio/archive/2007/07/18/822389.html 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v14 // 14th_convert 五. 抽象类 1. 抽象类概念 做一个"各个国家的人"的调查: 饮食、穿衣、开车.... Human : 向下定义好框架,向上提供统一的接口 Englishman Chinese 2. 抽象类界面 一个程序由多个人编写,分为: 应用编程:使用类 类编程:提供类,比如Englishman, Chinese app --------------------------------- Human.h --------------------------------- Englishman Chinese 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v15 // 15th_abstract 六. 模板 1. 函数模板 好文:理解模板参数推导,可以看下文: http://blog.csdn.net/coolmeme/article/details/43986163 要深入: C++标准之(ravalue reference) 右值引用介绍 http://www.cnblogs.com/opangle/archive/2012/11/19/2777131.html 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v16 // 16th_template 2. 类模板 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v17 // 17th_class_template 七. 异常 A > B > C > C() { return XX; } B() { if (C()) {} else return -Err; } A() { if (B()) {} else {} } A : setjmp C : longjmp c++: 异常 函数A捕捉函数C发出的异常 1. 谁捕捉异常?A 2. 谁抛出异常?C 3. 捕捉到异常后怎么处理?随A 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v18 // 18th_exception 八. 智能指针 1. 自己实现智能指针 源码下载方法 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v19 // 19th_smartpointer 2. Android轻量级指针 Android源码: frameworks/rs/cpp/util/RefBase.h, StrongPointer.h, TypeHelpers.h 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v20 // 20th_light_smartpointer 3. 弱指针的引入 4. 强指针和弱指针的实现与使用 头文件: system/core/include/utils system/core/include/cutils cpp: system/core/libutils/RefBase.cpp 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v21 // 21th_strongpointer_weakpointer 九. 设计模式 1. 单例模式 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v22 // 22th_singleton 2. 桥接模式 作用: 将抽象部份与它的实现部份分离,使它们都可以独立地变化 参考文章: http://www.cnblogs.com/jiese/p/3164940.html http://blog.csdn.net/wuzhekai1985/article/details/6670473 举例:给电脑(Mac, Lenovo)安装操作系统(Linux, Windows) 第一次: git clone https://github.com/weidongshan/cpp_projects.git 更新: git pull origin 取出指定版本: git checkout v23 // 23th_bridge_mode