C++ Literals

Literals are constant values that are directly inserted into the source code. They represent specific data values and are used to initialize variables or express values within expressions.

Types of Literals in C++

1. Integer Literals:

2. Floating-Point Literals:

3. Character Literals:

4. String Literals:

5. Boolean Literals:

6. Pointer Literals:

Example:

int decimal_int = 10;
int octal_int = 012;
int hex_int = 0xA;
int binary_int = 0b1010;
float float_num = 3.14f;
double double_num = 2.71828;
char character = 'A';
char newline_char = '\n';
std::string str = "Hello, world!";
std::wstring wstr = L"Wide string";
bool is_true = true;
bool is_false = false;
int* ptr = nullptr;