type

A type determines the properties of an object of that type, including its size in bytes, the range of possible values it can take, the operations that it supports, and so on.

Types can also be used as parameters for generic function and class templates, allowing a single template to operate on a wide variety of types. This ability has led to the much broader field known as template metaprogramming.

The  operator can be used to calculate the size, in bytes, of any object or type. is 1; the sizes of all other types are implementation-defined, subject to some constraints as noted below.

The headers &lt;climits&gt; (&lt;limits.h&gt; in C) and &lt;cfloat&gt; (&lt;float.h&gt; in C) define a battery of macros that specify properties for built-in types. The header &lt;limits&gt; enhances this by defining the traits class template, which can easily be extended to new types by specializing for those types.

Also, C++ provides a rudimentary reflection system called runtime type information (RTTI) which can be accessed using the  operator (in conjunction with the   class in &lt;typeinfo&gt;) or the   operator.

Integral types
Additionally, C++ specifies four basic integral types, in order of increasing size:


 * (or )
 * (or )
 * (or )
 * (or )

must be at least 8 bits,  and   must be at least 16 bits each, and   must be at least 32 bits. 

Each of these types allows the modifiers  or. Signed types typically have half the maximum absolute value of unsigned types, but have the ability to represent negative numbers. For instance, a signed 8-bit quantity might have a range from -128 to 127, inclusive, whereas an unsigned 8-bit quantity might have a range from 0 to 255.

''Note: Signed types have peculiar semantics when used as operands in bitwise operations. For this reason, it is recommended that you use unsigned types when dealing with the underlying bits rather than the quantities they represent.''

For all types but, the   keyword is implicit. For instance,  is the same as. On the other hand,  behaves either like   or , depending on the implementation. However, even on an implementation where (for instance)  happens to behave like ,   and   are still two distinct types.

Additionally, C++ specifies two more integral types:


 * can represent the values  or  . When converting to , zero becomes  , and any other value becomes.
 * is implemented internally in terms of the basic four types, depending on the implementation. It is also distinct from that type. For instance, even on an implementation where (for instance)  happens to be implemented in terms of ,   and   would be two distinct types.

''Note: Microsoft Visual C++ 6.0 erroneously considers  as a typedef for. This is not compliant with ISO C++.''

Floating-point types
C++ specified three floating-point types, listed here in order of increasing precision:



The bitwise representation of these types is implementation-defined. Variations on IEEE-754 are typical, but not required.

The  type is an incomplete type. Its two primary uses are as the return type of a function that does not return a value, and as part of pointer-to-, which can be used to point to any type.

''Note: There are other uses, such as casting an expression to  to make it clear that the result is not used; or filling an empty function parameter list to make it clear that the function does not accept parameters. However, these are both fairly clear in C++ without the use of .''

Compound types
Arbitrarily complex types can be composed using just the fundamental types and the following:


 * arrays contain one or more elements, all of the same type.
 * functions use a list of types describing the accepted parameters, as well as the returned result.
 * pointers and references can refer to other objects, and also to functions (which are not objects).
 * classes and structs can contain member functions and variables and define how they can be accessed.
 * unions are similar to classes, but their member variables share the same region of storage.
 * enumerations specify a range of values that may be assigned to a variable.
 * pointers-to-member can refer to a member function or variable of an object.