const char & char const

来源:互联网 发布:矩阵的秩 编辑:程序博客网 时间:2024/05/08 15:17
1.const char *p (read-only location ‘*p’ *p 不能再赋值,  但p可以再赋值):常量数据
p is a const char pointer, so the memory that p refer to is constant, that is you cant change it.

2.char * const p (read only variable p,  但所指内容*p我变变变) :常量指针

p is a constant char *, that is p is const char point, so p cant not be changed. p++ like operation is illegal.


3.char const *p (read-only location ‘*p’ *p 不能再赋值, 但p可以再赋值):常量数据

same as 1


4.const char * const p(read-only location ‘*p’ ,  read-only variable ‘p’) :常量数据 常量指针

p is constant pointer that refer to a constant memory.

p cant be changed, and *p can't be changed.

原创粉丝点击