Hi guys I'm new with C++, whats the difference between using const int n=1
and int n=1
, I dont understant what does const
do. Can you give me examples or something?
Asked
Active
Viewed 77 times
0

Embedded C
- 1,448
- 3
- 16
- 29

Reyneer Leon
- 356
- 2
- 14
-
1What do you thinl it possibly mean? – Mohit Jain Mar 23 '16 at 05:46
-
The concrete example can be answered, but otherwise this question is far too broad. Can you limit it down to that example? – Cheers and hth. - Alf Mar 23 '16 at 05:47
-
In the `const` case `n=42` const be compiled. – user4581301 Mar 23 '16 at 05:56
-
sorry if this is duplicated, its because im super new here, sorry :( – Reyneer Leon Mar 23 '16 at 06:00
1 Answers
2
With const int n=1
you cannot modify the value of n in your code, for example if you try to do n= 4
then it would cause an error,
but with simple int n=1;
you can always modify the value of n in your code like this
n= 4;
n=7;

Zia Qamar
- 1,694
- 1
- 15
- 35