what is the difference between local and global variable?
global variable
Collapse
X
-
I am new to C++ so this may not be the best explanation to your question. From my understanding a global variable is one that can be used by the whole program or function; whereas a local variable has a limited scope. A local variable does not share with the whole program.
Again, this my not be the best explanation, but as members here have helped me, I wish to try and do the same for others. -
Global variables are stored in data segment of memory whereas local variables are stored in stack memory.
~DavidComment
Comment