
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What are literals in C++?
A literal is any notation for representing a value within the source code. They just exist in your source code and do not have any reference a value in memory. Contrast this with identifiers, which refer to a value in memory.
There are several types of literals in C++. Some of the examples of literals are −
- "Hello" (a string)
- 3.141 (a float/double)
- true (a boolean)
- 3 (an integer)
- 'c' (a character)
Things that are not literals −
- bar = 0; (a statement)
- 3*5-4 (an expression)
- std::cin (an identifier)
- Related Articles
- What are literals in Java?
- What are Literals in Python?
- What are JSP literals?
- What are Boolean literals in Java?
- What are Boolean Literals in C++?
- What are Character Literals in C++?
- What are string literals in C#?
- What are integer literals in C#?
- What are Perl Numerical Literals?
- What are Perl String Literals?
- What are floating point literals in C#?
- What are string literals in C language?
- What are binary literals and digit separators in C# 7.0?
- What is the difference between character literals and string literals in Java?
- Integer literals vs Floating point literals in C#

Advertisements