why do we have to declare global variables in c++?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why do we have to declare global variables in c++??

Would the code still be the same if I had to declare the same variable in the main function? If not, how would they differ??

17th Jul 2023, 11:46 AM
Ramabele Bernard Lebelo
Ramabele Bernard Lebelo - avatar
1 Answer
+ 1
It's a long discussion that will take days to complete or understand, look at the meaning of linkage and storages in c++ You'll get the full context about the difference in global, local or static variables
17th Jul 2023, 6:00 PM
White Shadow
White Shadow - avatar