How do i put number on constant | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i put number on constant

so there is this line const int x; how can i put in x what value that i want and i dont mean by this way: const int x = 30; // assume that i want 30

10th Feb 2018, 3:49 PM
Benji Bogozini
Benji Bogozini - avatar
2 Answers
0
NVM i will use readonly
10th Feb 2018, 3:56 PM
Benji Bogozini
Benji Bogozini - avatar
+ 3
Well, the point of a constant is that it cannot be reassigned a value once it is declared, so your second example is the only way that you could assign it a value.
10th Feb 2018, 3:52 PM
Faisal
Faisal - avatar