Is there any difference between a variable declared as static
outside any function between C and C++. I read that static
means file scope and the varia
No, there's no difference between C and C++ in this respect.
Read this SO answer about what static
means in a C program. In C++ there are a couple of other meanings related to the use of static
for class variables (instead of instance variables).
Regarding global vars being static
- only from the point of view of memory allocation (they are allocated on the data segment, as all globals are). From the point of view of visibility:
static int var; // can't be seen from outside files
int var; // can be seen from outside files (no 'static')