In the following code:
int count(){
static int n(5);
n = n + 1;
return n;
}
the variable n
is instantiated only once a
It's quite likely that this variable will be handled just as ordinary global variable by gcc. That means the initialization will be statically initialized directly in the binary.
This is possible, since you initialize it by a constant. If you initialized it eg. with another function return value, the compiler would add a flag and skip the initialization based on the flag.