====== C - C++ Variables ======
^Type^Example^Usage^Comment^
|int|1|[] [] int| |
|long int|1L| |
|long long int|1LL| |
|double|1.0|[long] double| |
|float|1.0F| |
|char|'1'|[]char| |
|char*|"a string"|Automatically terminated with a null character.|
|wchar_t*|L"a string"|[]wchar_t| |
|char8_t*|u8"this is a UTF-8 string with a UTF-8 character: u2018"| |
|char16_t*|u"this is a UTF-16 string with a UTF-16 character: u2018"| |
|char32_t*|U"this is a UTF-32 string with a UTF-32 character: U00002018"| |
|bool|true, false| |
|binary|0b101|C++ 2014 standard.|
----
===== Declarations =====
Declarations use both intrinsic and user-defined types. The intrinsic types are:
[]char
[]wchar_t
[] [] int
float
[long] double
bool
----
The keyword **auto** can be used if C++ can determine the type of variable itself:
auto var = 1L; // The type of var is long int.
----
The keyword **decltype** extracts the type of an expression.
This type can then be used wherever a type name is used.
For example, the following example uses decltype to declare a second variable with same type as an existing variable:
decltype(var1) var2; // The type of var2 is the same as var1.