|
For details, please refer to my blog, which has the usage of CONST.
http://blog.csdn.net/lklklk/posts/1464574.aspx
const principle: It is best to use const in C ++ to modify the type before it.
Such as: const int a; and int const b ;, although the two have the same meaning, it is best to use the latter case, the latter is more readable, because: int const we can clearly see that const is Modify int, and in the previous method, we don't know the specific meaning of const so easily. From the latter method we can know that const refers to a constant integer. Int * const b refers to a constant pointer b. This pointer points to an integer, so the content of this pointer can be changed, but its pointer value, that is, the value of b cannot be changed. The corresponding int const * b, refers to Is a pointer b to the constant integer content, that is to say, the content of this b can be changed, but the content of the address pointed by the beginning b cannot be changed in the program through b.
volatile also applies to the above principles. |
|