Practice mode C++

What linkage do names declared inside an unnamed (anonymous) namespace have?

Correct answer D. Internal linkage, so they are visible only in that translation unit

Explanation

An unnamed namespace behaves as if it had a unique name in each translation unit, followed by an implicit using-directive. Since C++11, everything inside it has internal linkage, so it cannot clash with identically named entities in other .cpp files. It is the modern C++ replacement for declaring file-local functions and variables static.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.