关于const修饰的部分:
- 看左侧最近的部分
- 如果左侧没有,看右侧
char const *pStr1 = "helloworld"; //const 修饰char 指针指向的类型不能改变 指向的内容可以改变
char* const pStr2 = "helloworld"; //const修饰指针,表示指针只能指这个地址 指针不能改
char const * const pStr3 = "helloworld"; //两个都修饰 不能改
关于const修饰的部分:
char const *pStr1 = "helloworld"; //const 修饰char 指针指向的类型不能改变 指向的内容可以改变
char* const pStr2 = "helloworld"; //const修饰指针,表示指针只能指这个地址 指针不能改
char const * const pStr3 = "helloworld"; //两个都修饰 不能改