#include <iostream>
using namespace std;
int main() {
const int a = 20;
const int* b = &a;
cout<<"b* = "<<*b<<"\n";
int* c=const_cast<int *>(b);
*c=40;
cout<<"b* = "<<*b<<" a = "<<a;
return 0;
}
Why isn't assigning c*=40 change the value of a?
52 Views Asked by abid ul islam At
2
You are trying to modify a
constobject, this behaviour is undefined.From C++ spec section 10.1.7.1 point 4