Table of Contents

C++ Data Types

C++ programmers have access to the five data types for C: void, int, float, double, and char.

TypeDescription
voidassociated with no data type
intinteger
floatfloating-point number
doubledouble precision floating-point number
charcharacter

In addition, C++ defines two more: bool and wchar_t.

TypeDescription
boolBoolean value, true or false
wchar_twide character

Type Modifiers

Several of these types can be modified using the keywords signed, unsigned, short, and long. When one of these type modifiers is used by itself, a data type of int is assumed. A complete list of possible data types follows:

bool
char
unsigned char
signed char
int
unsigned int
signed int
short int
unsigned short int
signed short int
long int
signed long int
unsigned long int
float
double
long double
wchar_t

Type Sizes and Ranges

The size and range of any data type is compiler and architecture dependent. The “cfloat” (or “float.h”) header file often defines minimum and maximum values for the various data types. You can use the sizeof operator to determine the size of any data type (frequently expressed as a number of bytes). However, many architectures implement data types of a standard size. ints and floats are often 32-bit, chars 8-bit, and doubles are usually 64-bit. bools are often implemented as 8-bit data types.