Do inline namespace variables have internal linkage? If not, why does the code below work?
问题 This question is directly related to this one. Consider the code: #include <iostream> inline namespace N1 { int x = 42; } int x = 10; int main() { extern int x; std::cout << x; // displays 10 } It displays 10 . If I remove the extern int x; declaration 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 work, and why does it stop working when I remove it? Is it because inline namespace variables