const int num = 0;
const int *p = #//指向const类型的指针,指针值可以变
int num2 = 0;
int *const cp = &num2;//const指针,指针所指向的变量的值可以变
const int *const cpp = #//指针是不变的,指针所指向的变量的值也是不能变的...
typedef string* pstring;
const pstring strpc = NULL;//这个实际上是常量指针,相当于string *const strpc;
const int *cpArr = new int[10]();//数组中每个元素都是const int 类型
关于const的一点小花招
最新推荐文章于 2023-05-27 14:34:26 发布