Data Types in C++



All variables use data-type during declaration to restrict the type of data to be stored. Therefore, we can say that data types are used to tell the variables the type of data it can store. Whenever a variable is defined in C++, the compiler allocates some memory for that variable based on the data-type with which it is declared. Every data type requires a different amount of memory.

Data types in C++ is mainly divided into three types:
  1. Primitive Data Types: These data types are built-in or predefined data types and can be used directly by the user to declare variables. example: int, char, float, bool, etc. Primitive data types available in C++ are:
    • Integer - (Used to store Numbers)
    • Character - (Used to store characters)
    • Boolean - (True / False)
    • Floating Point - (Storing number with some precision)
    • Double Floating Point - (Same as Floating Point but with 8bytes Space)
    • Valueless or Void - (NULL)
    • Wide Character - (size greater than the traditional 8-bit character.)
  2. Derived Data Types: The data-types that are derived from the primitive or built-in datatypes are referred to as Derived Data Types. These can be of four types namely:
    • Function
    • Array
    • Pointer
    • Reference
  3. Abstract or User-Defined Data Types: These data types are defined by user itself. Like, defining a class in C++ or a structure. C++ provides the following user-defined datatypes:
    • Class
    • Structure
    • Union
    • Enumeration
    • Typedef defined DataType
Datatype Modifiers: As the name implies, datatype modifiers are used with built-in data types to modify the length of data that a particular data type can hold. Data type modifiers available in C++ are:
  • Signed
  • Unsigned
  • Short
  • Long
The table summarizes the different data types and the value in Range.


Here we have gone through the different types of data that can be manipulated in C++. In the next, we will be using these data types and will be writing programs to practice.

Thank You

Comments