
- 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
How to define constants in C++?
You can define constants in C++ by adding the const qualifier before the declaration of the variable.
Example
#include<iostream> using namespace std; int main() { const int x = 9; x = 0; return 0; }
This will define the constant variable x. But it will throw an error as we are trying to rewrite the value of a constant.
- Related Questions & Answers
- How to define character constants in C#?
- How do I define string constants in C++?
- How to define integer constants in JavaScript?
- What is a constant and how to define constants in Java?
- C# TicksPer constants
- How to create Variables and Constants in C++?
- Decimal constants in C#
- Difference between C++ string constants and character constants
- How to define methods in C#?
- How to define namespaces in C#?
- How to define variables in C#?
- What are constants in C++?
- How to implement constants in java?
- How to define a variable in C++?
- How to define custom methods in C#?
Advertisements