摘要: const表示只读,const关键字修饰的变量为只读变量。 const修饰的变量存放在内存中的全局(静态)区,在编译时即确定了变量的数值,变量一旦定义之后,不允许修改变量的数值,所以const变量必须在定义时进行初始化! 一、修饰一般变量: const int i=10; 和 int const i=10; 是等效的。 二、修饰指针变量时,注意const所在位置: const int *p; int const *p;//与上句含义相同,p指向的位置可变,但是对象的数值不可变 int * const p;//p指向的位... 阅读全文
posted @ 2013-05-14 18:24 反光镜的博客 阅读(157) 评论(0) 推荐(0) 编辑