The overloaded =
is really to assign to objects of the same type. Ex:
order = another_order;
What you are looking for is an overloaded conversion operator.
operator int() { return currentvalue; }
However this is generally not regarded as good practice, due to unknown conversions. An explicit
overload is much safer:
explicit operator int() {...}
However you would need to do:
int n = static_cast<int>(order);