Quote Originally Posted by freddyflintstone
const_cast works as well of course but the"style" guideline of most (authors) is to use static_cast to add const-ness.
Of course, it is better to use static_cast, because static_cast can only add const specifiers. It is not dangerous.
const_cast can remove const specifier, and should be avoided if possible (but it cannot be always avoided, for example when linking with libraries which don't use const specifiers).