首页 > 编程语言 >C++ Const Pointer

C++ Const Pointer

时间:2022-10-27 16:44:28浏览次数:44  
标签:Const 常量 指向 int C++ const Pointer ptr

Compaction* const compaction; //即该指针声明后不能再指向其他地址
这样记:const后边的内容为“常量”。
const int  ptr;   //ptr为常量,初始化后不可更改
int* const ptr;   //ptr为常量,初始化后不能再指向其它地址

const int* ptr;   //*ptr为常量,不能通过*ptr改变它指向的内容 
int const* ptr;   //*ptr为常量,同上

标签:Const,常量,指向,int,C++,const,Pointer,ptr
From: https://www.cnblogs.com/attack204/p/16832786.html

相关文章