> ## 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++ Study Notes
- URL: https://cms.yufeiran.com/en-c-primer-xue-xi-bi-ji/
- Published: 2022-05-06T05:29:51.000Z
- Updated: 2026-09-27T12:37:56.000Z
- Author: Feiran Yu
- Tags: study notes, #lang-en, #legacy-import

# C++ Primer

*C++ Primer* is a classic C++ book. Studying it helps build a deeper understanding of C++. Since computer graphics depends heavily on C++, I started learning from this book and recorded notes here.

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

## Chapter 15

Inheritance access modifiers: `public`, `protected`, and `private`.

`public`: all access permissions of base-class members remain unchanged in the derived class.

`protected`: all `public` members of the base class become `protected` members in the derived class.

`private`: all base-class members, whether `public`, `protected`, or `private`, become `private` members in the derived class.

In short, the access changes are shown below:

| Inheritance modifier | Base public | Base protected | Base private |
| -------------------- | ----------- | -------------- | ------------ |
| public               | public      | protected      | private      |
| protected            | protected   | protected      | private      |
| private              | private     | private        | private      |

## Chapter 17: Special Library Facilities

[Regular Expressions: A 30-Minute Tutorial](https://deerchao.cn/tutorials/regex/regex.htm?ref=cms.yufeiran.com)

## Code Repository

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

# C++ Related

## Inspecting OOP Memory Layout

Visual Studio’s `cl` tool can conveniently inspect the memory layout of a class.

Using Visual Studio 2022 as an example:

Find this in the Start menu:

Visual Studio 2022 -> x64 Native Tools Command Prompt for VS 2022

Switch to the current directory. If you need to switch drives, such as to drive D, enter `D:` first. Then run:

```text
cl /d1 reportSingleClassLayoutXXX [filename]

```

Here `XXX` is the class name, and `[filename]` is the source file.

For example, if the class name is `Milk` and the file is `decorator.cpp`:

```text
cl /d1 reportSingleClassLayoutMilk decorator.cpp

```

Then you can see the layout result for class `Milk`:

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

When a class has virtual functions, a vtable pointer is inserted at the beginning of the class. With multiple inheritance, each inherited base adds one.