next up previous
Next: About this document ... Up: class and struct Previous: When should I use

How do I cast types?

Remember that an explicit type conversion often reveals an error of conception. To cast a variable a into another type T, use one of the following:
static_cast<T>(a)      // explicit and standard conversion
dynamic_cast<T>(a)     // validity of object checked at run-time
reinterpret_cast<T>(a) // binary copy
const_cast<T>(a)       // changes the constness



Alexis Angelidis (PhD) 2005-01-11