Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


How does a using directive impact name visibility in namespaces?

  1. It hides all other names outside the namespace

  2. It makes all names within the namespace visible to its scope

  3. It makes the namespace itself invisible outside its scope

  4. It imports all names as private

The correct answer is: It makes all names within the namespace visible to its scope

The using directive is used to bring the names defined within a namespace into the current scope. This means that any names within the namespace will now be visible and accessible within the current scope. Option A is incorrect because it would hide all names, including the ones within the namespace. Option C is incorrect because it does not make the namespace itself invisible, it only hides the names within it. Option D is incorrect because importing names as private means they can only be accessed within the current file, not within the namespace. Therefore, the correct answer is B.