I had an article, but i lost it, it showed and described a couple of c/c++ tricks that ppl should be careful. One of them interested me but now that i am trying to replicate it I'm not being able to put it to compile.
The concept was that it is possible to change by accident the value of a const in c/c++
It was something like this:
const int a = 3; // I promisse i won't change a
const int *ptr_to_a = &a; // I still promiss i won't change a;
int *ptr;
ptr = ptr_to_a;
(*ptr) = 5; // I'm a liar, a is now 5
I wanted to show this to a friend but now I'm missing a step, does anyone know what's missing for it to start compiling and working?
ATM I'm getting invalid conversion from 'const int*' to 'int*' but when i read the article i tried and it worked great.