5in this piece of code was a literal constant.
1776always represents the value one thousand seven hundred seventy-six.
0(zero) character. And for hexadecimal, they are preceded by the characters
0x(zero, x). For example, the following literal constants are all equivalent to each other:
int. However, certain suffixes may be appended to an integer literal to specify a different integer type:
unsigned long long.
echaracter (that expresses "by ten at the Xth height", where X is an integer value that follows the
echaracter), or both a decimal point and an
double. Floating-point literals of type
long doublecan be specified by adding one of the following suffixes:
l) can be written using either lower or uppercase letters with no difference in meaning.
'), and to express a string (which generally consists of more than one character), we enclose the characters between double quotes (
xalone would refer to an identifier, such as the name of a variable or a compound type, whereas
'x'(enclosed within single quotation marks) would refer to the character literal
'x'(the character that represents a lowercase x letter).
\n) or tab (
\t). These special characters are all of them preceded by a backslash character (
|form feed (page feed)|
|single quote (|
|double quote (|
|question mark (|
"Left \t Right"
\) followed by the code expressed as an octal (base-8) or hexadecimal (base-16) number. For an octal value, the backslash is followed directly by the digits; while for hexadecimal, an
xcharacter is inserted between the backslash and the hexadecimal digits themselves (for example:
\) at the end of line is considered a line-continuation character that merges both that line and the next into a single line. Therefore the following code:
char. A different character type can be specified by using one of the following prefixes:
char16_tand uppercase for
L, two additional prefixes exist:
|The string literal is encoded in the executable using UTF-8|
|The string literal is a raw string|
R"sequence(and a final
sequenceis any sequence of characters (including an empty sequence). The content of the string is what lies inside the parenthesis, ignoring the delimiting sequence itself. For example:
"string with \\backslash". The
Rprefix can be combined with any other prefixes, such as
falseare the two possible values for variables of type
nullptris the null pointer value.
#define identifier replacement
identifierin the code is interpreted as
replacement, where replacement is any sequence of characters (until the end of the line). This replacement is performed by the preprocessor, and happens before the program is compiled, thus causing a sort of blind replacement: the validity of the types or syntax involved is not checked in any way.
#definelines are preprocessor directives, and as such are single-line instructions that -unlike C++ statements- do not require semicolons (;) at the end; the directive extends automatically until the end of the line. If a semicolon is included in the line, it is part of the replacement sequence and is also included in all replaced occurrences.
Variables and types