Fundamental types in C++ are divided into three categories: integral, floating point, and void. Integral types are capable of handling whole numbers. Floating point types are capable of specifying values that may have fractional parts.
The void type describes an empty set of values. No variable of type void can be specified — it is used primarily to declare functions that return no values or to declare generic pointers to untyped or arbitrarily typed data. Any expression can be explicitly converted or cast to type void. However, such expressions are restricted to the following uses:
An expression statement. (See Expressions, for more information.)
The left operand of the comma operator. (See Comma Operator for more information.)
The following table explains the restrictions on type sizes. These restrictions are independent of the Microsoft implementation.
Fundamental Types of the C++ Language
Type char is an integral type that usually contains members of the basic execution character set — By default, this is ASCII in Microsoft C++.
The C++ compiler treats variables of type char, signedchar, and unsignedchar as having different types. Variables of type char are promoted to int as if they are type signedchar by default, unless the /J compilation option is used. In this case they are treated as type unsignedchar and are promoted to int without sign extension.
Type bool is an integral type that can have one of the two values true or false. Its size is unspecified.
Type shortint (or simply short) is an integral type that is larger than or equal to the size of type char, and shorter than or equal to the size of type int.
Objects of type short can be declared as signedshort or unsigned short. Signed short is a synonym for short.
Type int is an integral type that is larger than or equal to the size of type shortint, and shorter than or equal to the size of type long.
Objects of type int can be declared as signedint or unsignedint. Signedint is a synonym for int.
__int8, __int16, __int32, __int64
Sized integer __int``n, where n is the size, in bits, of the integer variable. __int8, __int16, __int32 and __int64 are Microsoft-specific keywords. Not all types are available on all architectures. (__int128 is not supported.)
Type long (or longint) is an integral type that is larger than or equal to the size of type int.
Objects of type long can be declared as signedlong or unsignedlong. Signedlong is a synonym for long.
Larger than an unsigned long.
Objects of type long long can be declared as signedlong long or unsignedlong long. Signedlong long is a synonym for long long.
A variable of type wchar_t designates a wide-character or multibyte character type. By default, wchar_t is a native type, but you can use /Zc:wchar_t- to make wchar_t a typedef for unsigned short. The __wchar_t type is a Microsoft-specific synonym for the native wchar_t type.
Use the L prefix before a character or string literal to designate the wide-character type.
Type float is the smallest floating point type.
Type double is a floating point type that is larger than or equal to type float, but shorter than or equal to the size of type longdouble.
Microsoft specific: The representation of long double and double is identical. However, long double and double are separate types.
Type longdouble is a floating point type that is larger than or equal to type double.
The following table lists the amount of storage required for fundamental types in Microsoft C++.