- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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.
Advertisements