const修饰指针
const int *p; :const *p-> p可变但p指向的对象不能变
int const *p; :const *p-> p可变但p指向的对象不能变
int *const p; :const p-》p不能变,但p指向的对象可变
const int *const p;:const *const p-> 指针p和p指向的对象都不可变
以上四个有什么区别呢?
在判别的时候忽略类型名,先修饰哪个,就代表哪个不能改变。
用typedef重命名一个结构体指针,例子如下
const Stu_pst stu3系统先忽略类型名,即只剩const stu3,因为stu3是指针所以const是修饰指针
Stu_pst const stu4:同上