Namespaces in C++
- there is something called file level scoping in c
File scope is the scope of a file in C. static has nothing to do with scope.
static can affect either linkage, i.e. makes something invisible to the linker, or
it can affect duration, assigning something static memory till the end of the program.
staticmeans not on the stack
A variable may have three kinds of storage:
- In program’s Static Area
- On stack (during function call)
- On Heap (when you allocate using new/malloc)
Global variables are always stored in static area. But to store a local variable in static area, you need the keyword static. As a static variable is not allocated on stack, you can access the variable on subsequent calls. Also
statickeyword at global scope gives a variable internal linkage.Consequently the variable cannot be accessed from some other file using the extern qualifier.
Resource This is from a course on Systems Architecture, which should be very cool