1.const is used to modify ordinary variables, indicating constants, not recommended modifications, to a certain extent do not allow the modification (in fact, can be modified)
Pointer constant: The pointer (the value of the variable pointed to) itself is a constant, stating that it cannot change its own point to int* const p=&a;
Constant pointer: A pointer to a constant that can be modified to point to, but cannot modify, the value of a variable that points to a const int* p;
Interview must kill Skill:
Const appears on the left of * is a constant pointer
const int num = 19;
const INT * p = #//Pointer to constant
Common interview questions often take the following examples to fool people:
intMain () {intA =Ten; intb = -; Const int* p;//Const *P, which can be used without initialization, to indicate that *p is constant int*ConstP1 = &b;//const P, must initialize, otherwise error, indicates p is constant address int* PP1Const= &a;//error, no such wording, different from the usual function: int fun () const; Const int*Constp2=&a;//The const int* and int const* are the same, and must be initialized at the time of definition, because the const directly modifies the pointer P2 int Const*Constp3=&a;//P2 and P3 are the same effect, just consider the const on the left or right side of the *, not affected by the int}
Usage of the Const keyword in C + +