New course! Every coder should learn Generative AI!
Try a free lesson0
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??
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