C++ Data Types, User Defined, Derived data types Explain with example
C++ Data Types
Data types: -
C++ data types can
be classified as
1. Standard data types
2. Derived (extended data types)
3. User defined data types
The following
figure represents the detail of c++ data type classification
Standard data types:
Standard data types are used
to tell the compiler what type of data to be handled by an identifier. These
data types give complete details of the behavior of a data type. It is possible
to handle only one value at a time.C and C++ compilers supports the built in
data types.With the exception of void the basic data tyoes may have
several modifiers(signed,unsigned,long,short) may apply to the character and
integer basic data types.
Void: - The Void is used to represent the following
things
1) To
specify the return type of a function when it is not returning any value.
2)
To indicate an empty argument list to a function.
3)
Declaration of the generic pointer.
User defined data types:
User defined data
types are created by a user by using simple, derived, user defined data types
as per the user requirement. The user has to decide the functionality and
behavior of these data types. By using these data types to handle more than one
data type using single identifier For example structures and classes
Derived data types (extended
data types):
Derived data types are used to extend the behavior
of an existing simple data type to get more functionality. It is possible to
handle more than one value at a time using a single identifier. For example
arrays.
The following table gives the details regarding
various data types.
data type Size in bytes Range
1) Char 1 -128 to 127
2) Unsigned Char 1 0 to 255
3) Signed Char 1 -128 to 127
4) int 2 -32768 to 32767
5) Unsigned int 2 0 to 65,535
6) Signed int 2 -32768 to 32767
7) Short int 2 -32768 to 32767
8) long
int 4 -2147483648 to 2147483647
9) float 4 1.2e-38 to 3.4e38
10) double 8 2.2e-308 to 1.8e308
11) long double 10 3.4e-4932 to 1.1e+4932