const_cast with example

const_cast<type> (expr): The const_cast operator is used to explicitly override const and/or volatile in a cast. The target type must be the same as the source type except for the alteration of its const or volatile attributes. This type of casting manipulates the const attribute of the passed object, either to be set or removed.

This type of casting manipulates the constness of the object pointed by a pointer, either to be set or to be removed.

See the below code snippet

Recommended Tutorials: