Datatypes in C++
Datatypes in C++
Overview
Introduction to C++
What are datatypes
Datatypes in C++ :
Primary
Derived
User-defined
Conclusion
Introduction to C++
C++ is a general-purpose programming language and is widely used nowadays for
competitive programming. It was developed to enhance the C language with
object-oriented programming.
Features of C++:
It is an object-oriented programming language
It is a mid-level language.
It is a machine independent but platform-dependent language
It has a rich library support
It has a high speed of execution.
Datatypes
in C++
User
Primitive Derived
Defined
• Int
• Function • Class
• Char
• Array • Structure
• Double
• Pointer • Union
• Boolean
• Reference • Enum
• Void
Primitive Datatypes
These datatypes are built-in or predefined in the language itself. They can directly
be used to declare the variables.
Primitive datatypes are of the following types:
Integer
Character
Boolean
Floating Point
Double Floating Point
Void or Valueless
Wide Character
The sizeof() operator is used to find out the number of bytes occupied by the
datatype in the memory.
Data Type Size(in bytes)
Char 1
Int 4
bool 1
Float 4
double 8
This code demonstrates the use to sizeof operator The output of the previous code. Results may
to find the memory occupied by a primitive vary from machine to machine
datatype in your computer
Derived Datatypes
These are datatypes which have been derived from built-in datatypes.
Primarily they are of the following types:
Function
Array
Pointer
Reference