相关疑难解决方法(0)

为什么编译器允许你在这里"写"一个const变量?

为什么你这样欺骗编译器:

const int a = 5;
*((int*)&a)=5;   // VC/armcc does not complain
Run Code Online (Sandbox Code Playgroud)

当上面的"删节"相当于此:

const int *ptr2const = &a;
int *ptr = ptr2const;      // as expected error is raised here
*ptr = 5;
Run Code Online (Sandbox Code Playgroud)

c c++ pointers const

3
推荐指数
2
解决办法
1215
查看次数

标签 统计

c ×1

c++ ×1

const ×1

pointers ×1