static int count;
int main()
{
static int count;
}
Is there any difference between static variables declared inside and outside any function?
(I mean the scope and visibility of the variable count)
Your first count
is only accessible within the module (code in that file). Your second count
is only accessible within main
.
When you declare outside of method it will be available to all static method functions written after its declaration. While declaring static variable in method will be accessible by only that method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With