June 2025
Intermediate to advanced
1093 pages
33h 24m
English
Literals are fixed, concrete values directly written in the source code. In C++, these can be integers, floating-point numbers, characters, or strings. The basics are the easily recognizable forms 123 and 3.141592 for numbers, 'a' as a single character, and "Gugelhupf" as a string.
It only becomes a bit more complicated because there are prefix and suffix modifiers for these base literals. As you have already seen in Chapter 4, Section 4.4, there are the following forms for integers, floating-point numbers, Boolean values, and strings:
999 0xffff 0777 0b10101 1L 0u // integer forms72.75 1e+10 3.141592f // floating point'a' "Text" // stringstrue false // truth values, the two bool literalsnullptr // the only nullptr_t literal ...
Read now
Unlock full access