> ## Content Index
> Fetch the complete content index at: https://cms.yufeiran.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# C++ 学习笔记
- URL: https://cms.yufeiran.com/c-primer-xue-xi-bi-ji/
- Published: 2022-05-06T05:29:51.000Z
- Updated: 2026-09-27T12:37:55.000Z
- Author: Feiran Yu
- Tags: 学习笔记, #legacy-import

# C++ Primer

C++ Primer是一本C++经典著作，学习它对于深入了解C++有好处，而图形学大量依赖C++，故我进行学习这本书，记录在此。  

![v2-59ab4eb7a1576a5b61a4f90ae74fbbf4_720w](https://yufeiran.com/content/images/2022/05/v2-59ab4eb7a1576a5b61a4f90ae74fbbf4_720w.jpg)

## 15章

类继承的修饰方式：public、protected、private  
public：基类所有对象访问权限保持原样到派生类  
protected：基类所有public对象在派生类中变为protected对象  
private：基类所有对象（public、protected、private）在派生类中变为private对象  
总之，派生类继承基类对象的权限变化如下表

| 修饰方式      | 基类public  | 基类protected | 基类private |
| --------- | --------- | ----------- | --------- |
| public    | public    | protected   | private   |
| protected | protected | protected   | private   |
| private   | private   | private     | private   |

## 17章 标准库特殊设施

[正则表达式30分钟入门教程](https://deerchao.cn/tutorials/regex/regex.htm?ref=cms.yufeiran.com)

## 代码仓库

[CPP\_Primer\_Practice](https://github.com/yufeiran/CPP%5FPrimer%5FPractice?ref=cms.yufeiran.com)

# C++相关

## 查看OOP内存分布

使用visual studio 的 cl 工具可以很方便的查看类的内存布局：  
以visual studio 2022为例：  
在开始菜单里找到  
visual studio 2022->x64 Native Tools Command Prompt for VS 2022  
切换到当前目录（如果要切换盘符如切到D盘需要先输入 D:)，然后输入下列命令：  
cl /d1 reportSingleClassLayoutXXX \[filename\] ,其中XXX是类名，\[filename\]是文件名，  
比如一个类名是Milk，文件是decorator.cpp:  
cl /d1 reportSingleClassLayoutMilk decorator.cpp  
就可以看到Milk类的结果：

![—–2024-03-26-113559](https://yufeiran.com/content/images/2024/03/-----2024-03-26-113559.png)

拥有虚函数时，会在类的起始处插入vtable指针，多重继承每个继承插入一个。