C++ Data Types

The above topic can also be referred to as Object Types. But since we have not yet introduced the concept of Object Oriented Programming we restrict ourselves to “data types”.

We now consider the fundamental data types on C++ which fall into three major divisions:

  • The integer data type
  • The floating point data type
  • The character data type

Integer Data Type
The basic integer object is called int which stands for integer. The C++ language does not explicitly specify the size of an int (the size in bits or bytes). The size is dependent on both the compiler and the system.
For most systems, the size of an int is 16bits which can represent integer values ranging from -32,768 to 32,767. Some systems support integer values of 32 or even 64 bits.
Two other integer data types include the short and the long which are presented in the table. Again there is no specification, but the generally the number of bits in short is no more than for int and the number of bits for long is not less than int.

Floating Point Data Types
Floating-point data types are used to represent real numbers that is numbers with decimal point. E.g
has an integer part of 6 and a fractional part of .626. Just like the integer data type C++ does not specify the size of floating point numbers it depend on the compiler and system under consideration.
The accompanying table shows the various data type sizes for the turbo C++ compiler.

The Character Data Type
Character data type denoted by the keyword char uses a single byte of storage to hold data. A character is an 8 bit integer value. Normally, characters are signed and have the range of
-128 to 127.

Table of Data Types in C++


The String Data Type
Remember that the various data types we’ve been discussing so far are refered to as fundamental types. Now, the string data type in C++ is not a fundamental type but an object.
That object contains data, namely the sequence of characters that make up the string.
There is no fixed memory size for the string objects since this is dependent on the number of characters in the string.

Leave a Reply

Your email address will not be published.