【发布时间】:2012-08-04 18:11:46
【问题描述】:
如果我创建一个 const 值的全局数组,例如
const int SOME_LIST[SOME_LIST_SIZE] = {2, 3, 5, 7, 11};
可以以任何方式修改 SOME_LIST 吗?
如何编写这样的 SOME_LIST 指向一个 const 内存位置,并且本身就是一个 const 指针(即不能指向其他地方)?
【问题讨论】:
-
SOME_LIST无论如何都不能修改 -
SOME_LIST是 an array, not a pointer,所以只需要担心一层常量。
标签: c++ arrays constants const-correctness