Identifiers are names that are used in C++ programs for functions, parameters, variables, constants, classes, and types. An identifier consists of a sequence of letters, digits, and underscores that does not begin with a digit. An identifier cannot be a reserved keyword. See Appendix A for a list of them. The standard does not specify a limit to the length of an identifier, but certain implementations of C++ only examine the first 31 characters to distinguish between identifiers.
A literal is a constant value that appears somewhere in a program. Since every value has a type, every literal has a type also. It is possible to have literals of each of the native data types, as well as character string literals. Table 1.1 shows some examples of literals.
Literal |
Meaning |
---|---|
5 |
an int literal |
5u |
u or U specifies unsigned int |
5L |
l or L specifies long int after an integer |
05 |
an octal int literal |
0x5 |
a hexadecimal int literal |
true |
a bool literal |
5.0F |
f or F specifies single precision floating point literal |
5.0 |
a double precision floating point literal |
5.0L |
l or L specifies long double if it comes after a floating point |
'5' |
a char literal (ASCII 53) |
"50" |
a const char* containing the chars '5', '0', and ' |