Hi,
I have the following code:
#include <iostream>
using namespace std;
int main()
{
const int x = 1;
int *y = const_cast<int* >(&x);
*y = 2;
cout << &x <<": "<< x << endl;
cout << y <<": "<< *y << endl;
return 0;
}
The above code produces the following output:
0xbffff49c: 1
0xbffff49c: 2
How is it that they can both have the same address but different values?
I have the following code:
#include <iostream>
using namespace std;
int main()
{
const int x = 1;
int *y = const_cast<int* >(&x);
*y = 2;
cout << &x <<": "<< x << endl;
cout << y <<": "<< *y << endl;
return 0;
}
The above code produces the following output:
0xbffff49c: 1
0xbffff49c: 2
How is it that they can both have the same address but different values?
Comment