c/c++ 指针常量和常量指针

const pointer
int* const p = #
pointer to const
const int* p = #
常量指针指针常量也不知道哪个憨批翻译的翻译的像坨屎这是人类能分辨的东西吗

 
其实c++中的引用就是,和const pointer一样
int a = 55;
int& b = a;
int* const c = a;
2和3句在汇编后是一样的
指路->(不过不要管他是指针常量还是常量指针)
http://www.manongjc.com/detail/23-sjlloskcpwlsukd.html
 
 
 

翁恺老师关于这些内容的课指路,讲的真好
https://www.icourse163.org/learn/ZJU-9001?tid=9001#/learn/content?type=detail&id=142003&cid=166048
 
 
这样记:const后边的内容为“常量”。
const int ptr; //ptr为常量,初始化后不可更改
const int* ptr; //\*ptr为常量,不能通过\*ptr改变它指向的内容
int const* ptr; //\*ptr为常量,同上
int* const ptr; //ptr为常量,初始化后不能再指向其它地址

markdown创建空行 

posted @ 2022-04-09 21:39  莫须有-  阅读(39)  评论(0)    收藏  举报