what is the use of const keyword in c++ ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the use of const keyword in c++ ?

13th Sep 2016, 6:49 PM
Sandeep Singh
Sandeep Singh - avatar
1 Answer
+ 1
It is used to declare constants. The affected variable cannot be reassigned a value. const int ANSWER = 42; ANSWER = 1337; //won't work, ANSWER is still 42
14th Sep 2016, 8:56 AM
Zen
Zen - avatar