const int x = 50;
int* y = (int *)(&x);
*y = 200;
cout << "x: "<<x<<" address: "<<&x<<endl;
cout << "*y: "<<*y<<" address: "<<y<<endl;
cout<<endl;
以上是一段代码,输出的结果是:x: 50 * y=200 地址是一样的.
但是如果我把int改成float或者double那么值就都变成了200..
是不是因为原来为int型,一个地址存放了两个值,float型比较长,无法存放两个值
求解答~~