Reinterpret Cast

This lesson highlights the key features of the reinterpret_cast operator.

We'll cover the following

Features #

  • reinterpret_cast allows us to convert a pointer of a particular type to a pointer of any other type, regardless of whether the types are related or not.

  • It also allows conversion between a pointer and an integral.

  • reinterpret_cast guarantees that if a pointer is cast into another type, casting it back would return the original value.

  • The use of reinterpret_cast is not recommended as it does not take any safety measures before converting between types. This can result in faulty or accidental conversions that could harm the code.

Example #

Get hands-on with 1200+ tech skills courses.