According to the C++23 standard, what is the output of this program?
#include <iostream>
int a;
int main () {
std::cout << a;
}Is a static? And what do we mean by "static" anyway? Think about the difference between static storage duration and external linkage.
0
Since a has static storage duration and no initializer, it is guaranteed to be zero-initialized. Had a been defined as a local non-static variable inside main(), this would not have happened.
Note: int a has static storage duration because it is declared at namespace scope. It does not need to have static in front of it, that would only denote internal linkage.