Skip to content

Instantly share code, notes, and snippets.

@jitpaul
Created November 23, 2019 16:25
Embed
What would you like to do?
const_cast
int a = 5;
const int* b = const_cast <const int*> (&a);
int* c = const_cast<int*> (b);
a = 10; //OK
*b = 4; //ERROR
*c = 6; //OK
int d = 5;
const int& e = const_cast<const int &> (d);
int& f = const_cast<int&>(e);
d = 10; //OK
e = 4; //ERROR
f = 6; //OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment