As the name suggests, user defined data types are defined by the programmers(you) during the development of a software.
These four user defined data types are :
- Structure
- Union
- Class
- Enumerator
We will study these data types in further chapters.
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.
Typecasting
Below statement allows the programmer to convert one data type into another data type.
Syntax
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