【C/C++】顶层const与底层const总结

const修饰规则

const int *p1 可看作是const修饰的类型是int,修饰的内容是*p1,即*p1不允许改变。
int const *p2 可以看作const修饰的类型是int,修饰的内容是*p2,即*p2不允许改变。
int *const p3 可以看作const修饰的类型是int *,修饰的内容是p3,即p3不允许改变

猜你喜欢

转载自blog.csdn.net/qq_37286579/article/details/130563920