C++ Tutorials

C++ Tutorials

In C++ object oriented language, smaller memory data type variable can be converted to larger data type by the compiler.

Type conversion can be done by two ways:

Automatic Type Conversion

When an expression consists of more than one type of data elements, the C++ compiler converts the smaller data type elements into larger data type element. This process is known as implicit or automatic conversion.


Below statement allows the programmer to convert one data type into another data type.


 aCharVar = static_cast<char>(an IntVar)

Here in the above syntax char variable will be converted into int variable after execution.

The C++ language has four typecast operators:

  • static_cast
  • reinterpret_cast
  • const_cast
  • dynamic_cast