"Mark" <mn*******@gmail.comwrote in message
news:11**********************@v29g2000prd.googlegr oups.com...
On Oct 15, 5:20 pm, Mark <mnbaya...@gmail.comwrote:
>Hi,
So I came across some source code... "static int slices = 16;" which
is outside of any class or function. I know what statics are used for
inside classes/functions, but what does it mean if it's global?
Perhaps my C++ is getting a bit rusty...
nvm... my girlfriend found the answer (out of all people!). I guess
my googling skills are getting a bit rusty too:
A static global variable is never visible outside of its file, even
in the presence of ``extern'' declarations. global variable is a
variable that is accessible in every scope
Yes, just to give you a little more information, it's not necessary that
"file" but that "translation unit". So a file that is included could still
see the same instance of the variable because its the same "translation
unit". A translation unit is a group of files that gets compiled to an
object file. Normally, but not always, this is one .cpp with whatever
header files it includes. At the end of compiling the translation units
(which are now object files) get linked together to form an executable.