"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:cj**********@nntp1.jpl.nasa.gov...
Vipul Jain wrote:
Can any one please tell me what is the difference between global scope
and file scope of an variable.
> cat file.cc
int a = 0; // global scope
static
int b = 0; // file scope
I don't agree with that. The way I was tought it scope deals only with
visibility of a name in code. Without extra help (an extern declaration),
"a" is visible only within the translation unit file.cc, so it has file
scope. As such, true global scope doesn't exist in C++, and the term global
scope is frequently used to refer to file scope. So as Victor said, there is
no difference.
According to the terminology I know, "a" has external linkage and "b" has
internal linkage, but they both have the same scope (file) and lifetime
(application).
--
Unforgiven