S
shaun
If I put (define) const variables at the top of a .cpp file but do not
declare them in the .h file, are they only visible within that .cpp file?
e.g.
const int a[]={1,2,3,4};
in a cpp file will be a 'global' with file scope? (no flames for
oxymoron, please), available for use inside my functions which are
defined in the same file (but which are also declared in the .h)?
On trying it, this appears to be true, but then:
In this case, what does the 'static' keyword lend to the definition?
Schildts' book (C++ The complete reference) tells me that "Applying the
specifier static to a global variable instructs the compiler to create a
global variable that is known only to the file in which you declared it."
cheers
shaun
declare them in the .h file, are they only visible within that .cpp file?
e.g.
const int a[]={1,2,3,4};
in a cpp file will be a 'global' with file scope? (no flames for
oxymoron, please), available for use inside my functions which are
defined in the same file (but which are also declared in the .h)?
On trying it, this appears to be true, but then:
In this case, what does the 'static' keyword lend to the definition?
Schildts' book (C++ The complete reference) tells me that "Applying the
specifier static to a global variable instructs the compiler to create a
global variable that is known only to the file in which you declared it."
cheers
shaun