考虑一下:
#include <iostream>
using namespace std;
int main(void)
{
const int a1 = 40;
const int* b1 = &a1;
char* c1 = (char *)(b1);
*c1 = 'A';
int *t = (int*)c1;
cout << a1 << " " << *t << endl;
cout << &a1 << " " << t << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这个输出是:
40 65
0xbfacbe8c 0xbfacbe8c
Run Code Online (Sandbox Code Playgroud)
除非编译器进行优化,否则这对我来说几乎是不可能的.怎么样 ?