[C++] Pointer constant, constant pointer, constant pointer to constant

1. Concept

First, clarify the specific meanings of these terms:

  1. Pointer constant (constant pointer): English is: const pointer, that is, the pointer itself is a constant
  2. Constant pointer: English is: poiner to const, that is, the target pointer cannot be modified through this pointer
  3. Constant pointer pointing to a constant: English is: a constant pointer to a constant, the pointer itself is a constant, and the target pointer cannot be modified through this pointer

You can quickly understand the meaning of these terms from English, but due to translation problems, everyone will be very confused when they first learn C++. They are confused by these concepts. Also due to translation problems, there are
still The following set of terms:

  1. Constant pointer: The pointer itself is a constant. This version of the translation mainly emphasizes that the pointer itself is a constant.
  2. Pointer to constant: that is, the target pointer cannot be modified through this pointer. The Chinese name of this group can be understood at a glance.
  3. Constant pointer to a constant: The pointer itself is a constant, and the target pointer cannot be modified through this pointer.

The second group of translations and the first group of translations have two completely different results at the position of the constant pointer. Perhaps this is why many people do not feel that they are very consistent when searching for articles online. Some articles follow the If one group of translations explains the meaning, and another part of the article is interpreted according to the second group, it will make the reading more confusing.

To prevent readers from misunderstanding, I will use English names instead of Chinese names in the future. In addition, readers do not need to worry too much about Chinese names. They only need to be able to clearly distinguish the definitions and usages const pointerof poiner to constand

2. const pointer

3. poiner to const

4. a constant pointer to a constant

5. Tu Yile

Guess you like

Origin blog.csdn.net/FuckerGod/article/details/133088742