Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 583 Bytes

reinterpretcast.md

File metadata and controls

36 lines (21 loc) · 583 Bytes

Explicit Casting

In the C++ language, you can use the following methods to convert or cast data from one type to another.

  • C styled casts
  • reinterpret_cast
  • dynamic_cast
  • static_cast
  • const_cast

C Styled Casts

In the standard C++ and C language, you can convert or "cast" similiar types of data. For instance:

char myInitial = 'N';
int myInitialAscii = (int)myInitial;
// OR
int myInitialAscii = int(myInitial); // Familiar to the python programmer

dynamic_cast

  • Used with pointers and references
    • or void*

reinterpret_cast