I need to change a value of a static const int
member. I know it’s a bit stranger thing but I need it to overcome a limitation given by framework I’m using!
I’ve already try, but it doesn’t work, it rises an error saying “undefined reference to MyClass::staticConstMember”:
class MyClass
{
static const int staticConstMember = 10;
};
int main()
{
int* toChageValue = const_cast<int*>(&MyClass::staticConstMember);
toChangeValue = 5;
std::cout<<MyClass::staticConstMember<<std::endl; // here I need to print 5
Return 0;
};