and the English version of the pair:
As we ' ve seen, a pointer is an object and can point to a different object. As a result,
We can talk independently on whether a pointer is const and whether the objects
To which it can point is const. We use the term top-level const to indicate the
Pointer itself is a const. When a pointer can point-to-a const object, we refer to
That const as a low-level const.
-----------------------------------------------------------------
The English language is obvious: the top-level const (TOP-LEVEL-CONST)-----The pointer itself is a constant, and the underlying const (low-level const) pointer refers to the object that is a constant.
1 const Qualifier and pointer2 Const int* p;//Const on the left, indicates that *p is constant and cannot be changed (via *p cannot change what the pointer points to)3 //but the pointer p or the variable, want to change all can. This is called the underlying const.4 Example:5 intb = A;6 Const int*p;7p = &b;8 //* p = 200; //Error *p is a constant and can no longer be assigned to a constant value9 Ten One int*Constp = &b;//must be initialized at the same time as the Declaration, const on the right side of the *, indicating that P is constant, p points to the address A //is immutable, so when the address of B is assigned to it, an error is given. This is the so-called top-level const - Example: - intb = -; the intc = A; - int*Constp = &b;//must be initialized at the same time as the Declaration, const on the right side of the *, indicating that P is constant, p points to the address - //is immutable, so when assigning the address of B to it, an error is given . - //p = &c; //Error p is constant, top-level const + - + Const int*ConstP//This is equivalent to the mixture of the above two cases, p is a constant, A //Therefore, the Test2 address can not be assigned to P, while *p is also constant, so the contents of *p cannot be changed; at Example: - intTest1 =Ten; - intTest2 = -; - Const int*Constp = &test1; -p = &test2;//Error,p is a constant, so the address of test2 cannot be assigned to P; -*p = -;//Error,*p is constant, so the contents of *p cannot be changed;
2nd. Variables and basic Types 3---Underlying const and top-level const