|
1 | 1 | --- |
2 | | -title: "this pointer" |
| 2 | +title: "The this pointer" |
3 | 3 | description: "The this pointer is a compiler-generated pointer to the current object in nonstatic member functions." |
4 | 4 | ms.date: "01/22/2020" |
5 | 5 | f1_keywords: ["this_cpp"] |
6 | 6 | helpviewer_keywords: ["nonstatic member functions [C++]", "pointers, to class instance", "this pointer"] |
7 | 7 | ms.assetid: 92e3256a-4ad9-4d46-8be1-d77fad90791f |
8 | 8 | no-loc: [this, class, struct, union, sizeof, const, volatile] |
9 | 9 | --- |
10 | | -# this pointer |
| 10 | +# The `this` pointer |
11 | 11 |
|
12 | 12 | The **`this`** pointer is a pointer accessible only within the nonstatic member functions of a **`class`**, **`struct`**, or **`union`** type. It points to the object for which the member function is called. Static member functions don't have a **`this`** pointer. |
13 | 13 |
|
@@ -131,7 +131,7 @@ my buffer |
131 | 131 | your buffer |
132 | 132 | ``` |
133 | 133 |
|
134 | | -## Type of the this pointer |
| 134 | +## Type of the `this` pointer |
135 | 135 |
|
136 | 136 | The **`this`** pointer's type can be modified in the function declaration by the **`const`** and **`volatile`** keywords. To declare a function that has either of these attributes, add the keyword(s) after the function argument list. |
137 | 137 |
|
@@ -161,15 +161,15 @@ int main() |
161 | 161 | } |
162 | 162 | ``` |
163 | 163 |
|
164 | | -The type of **`this`** in a member function is described by the following syntax. The *cv-qualifier-list* is determined from the member function's declarator. It can be **`const`** or **`volatile`** (or both). *class-type* is the name of the class: |
| 164 | +The type of **`this`** in a member function is described by the following syntax. The *`cv-qualifier-list`* is determined from the member function's declarator. It can be **`const`** or **`volatile`** (or both). *`class-type`* is the name of the class: |
165 | 165 |
|
166 | | -[*cv-qualifier-list*] *class-type* **\* const this** |
| 166 | +[*`cv-qualifier-list`*] *`class-type`* **`* const this`** |
167 | 167 |
|
168 | | -In other words, the **`this`** pointer is always a const pointer. It can't be reassigned. The **`const`** or **`volatile`** qualifiers used in the member function declaration apply to the class instance the **`this`** pointer points at, in the scope of that function. |
| 168 | +In other words, the **`this`** pointer is always a **`const`** pointer. It can't be reassigned. The **`const`** or **`volatile`** qualifiers used in the member function declaration apply to the class instance the **`this`** pointer points at, in the scope of that function. |
169 | 169 |
|
170 | 170 | The following table explains more about how these modifiers work. |
171 | 171 |
|
172 | | -### Semantics of this modifiers |
| 172 | +### Semantics of `this` modifiers |
173 | 173 |
|
174 | 174 | |Modifier|Meaning| |
175 | 175 | |--------------|-------------| |
|
0 commit comments