Understanding C++ linkage and variable scope
This is an easy C++ question that tests your knowledge of linkage—a core concept in how the compiler and linker resolve global variable declarations across translation units. It's the kind of foundational question that appears in technical interviews to confirm you understand how C++ manages symbol visibility at the language and linking levels.
The question asks you to distinguish between keywords that alter a global variable's default external linkage (making it internal to a single translation unit) versus those that do not. To answer it correctly, you need to be familiar with how C++17 handles namespace scope, the static keyword, anonymous namespaces, and related mechanisms for controlling linkage visibility.
- External vs. internal linkage in C++
- Translation unit boundaries
- The
static keyword and unnamed namespaces
- Storage class specifiers and their linkage effects