

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between literal and constant in C++?
A literal is a value that is expressed as itself. For example, the number 25 or the string "Hello World" are both literals.
A constant is a data type that substitutes a literal. Constants are used when a specific, unchanging value is used various times during the program. For example, if you have a constant named PI that you'll be using at various places in your program to find the area, circumference, etc of a circle, this is a constant as you'll be reusing its value. But when you'll be declaring it as −
const float PI = 3.141;
The 3.141 is a literal that you're using. It doesn't have any memory address of its own and just sits in the source code.
- Related Questions & Answers
- What is the difference between literal and constant in C#?
- What is the difference between `new Object()` and object literal notation in JavaScript?
- What is different between constant and variable in C++?
- What is the difference between a String object and a String literal in Java?
- What is the main difference between objects created using object literal and constructor function?
- What is the difference Between C and C++?
- What is the difference between JavaScript and C++?
- What is the difference between | and || operators in c#?
- What is the difference between C++0x and C++11?
- What is the difference between ++i and i++ in c?
- What is the difference between ++i and i++ in C++?
- What is the difference between declaration and definition in C#?
- What is the difference between objects and classes in C#?
- What is the difference between overriding and hiding in C#?
- What is the difference between overriding and shadowing in C#?
Advertisements