This question is directly related to this . Consider the code:
#include <iostream> inline namespace N1 { int x = 42; } int x = 10; int main() { extern int x; std::cout << x; // displays 10 }
10 displayed. If I remove the extern int x; declaration extern int x; then we get an ambiguity compiler time error
error: reference to 'x' is ambiguous
Question: why does the code work with the extern int x declaration and why does it stop working when I delete it? Is this because inline space variables have an internal relationship?
c ++ c ++ 11 linkage
vsoftco
source share