《C++ Primer Plus 6th》读书笔记

1. 过程性编程和面向对象编程

2. 抽象和类

1. 使用类对象的程序都可以直接访问公有部分,但只能通过公有成员函数(或友元函数)来访问对象的私有成员

2. 可以在类声明之外定义成员函数,并使其成为内联函数

3. 类的构造函数和析构函数

1. 接受一个参数的构造函数允许使用赋值语法将对象初始化为一个值

4. this指针

5. 对象数组

6. 类作用域

1. 以下类定义方式是错误的,应为在声明类前Month不存在

1 class Bakery
2 {
3 private:
4     const int Month = 12;
5     double costs[Month];
6 }

可以通过两种方式解决

 1 class Bakery 
 2 {
 3 private:
 4     enum {Month = 12}; // 枚举
 5     double costs[Month];
 6 };
 7 
 8 class Cakery 
 9 {
10 private:
11     static const int Month = 12; // 静态
12     double costs[Month];
13 };

7. 抽象数据类型

原文地址:https://www.cnblogs.com/Azurewing/p/4316812.html