In this lecture, we delve into the different types of literal constants available in C++. This extends from the foundational concepts of literal constants discussed in previous lectures.
int A = 10;
0x
, digits from 0 to 9 and A-F.
int B = 0x1A; // 26 in decimal
0
, digits from 0 to 7.
int C = 032; // 26 in decimal
B
, digits 0 and 1.
int D = B1010; // 10 in decimal
u
or U
: Unsigned integers.l
or L
: Long integers.ul
, Lu
: Unsigned long integers.ll
or LL
: Long long integers.ull
, LLU
: Unsigned long long integers.4.5
f
or F
): 4.5f
double X = 4.5;
float Y = 4.5f;
e
for scientific notation.
double Z = 5.2e5; // 5.2 * 10^5
'A'
).'A'
'\n'
'A'
is 65 in ASCII)."Hello"
).const char* name = "Alice";
std::string greet = "Hello World";
\0
) at the end.true
or false
.bool isReady = true;
bool isEmpty = false;
true
is equivalent to 1
.false
is equivalent to 0
.true
.This lecture covers the types and representations of literal constants in C++. Understanding these types are crucial for effective programming in C++. Thank you for participating in this session. The next lecture will continue to expand on these concepts.