Why are constants defined outside the main function in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why are constants defined outside the main function in c++?

19th Dec 2016, 11:07 AM
kwenaldo
kwenaldo - avatar
2 Answers
+ 2
it is not necessary to define constant outside the main function. but if you want to access that constant anywhere in the program, you have to make that constant global that's why it is placed outside main function.
19th Dec 2016, 12:06 PM
Ravi Kumar
Ravi Kumar - avatar
+ 1
oh i see, thank you.
19th Dec 2016, 12:09 PM
kwenaldo
kwenaldo - avatar