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!

Practice this question and more.


What is the effect of a using declaration for a function name within a namespace scope?

  1. It imports the function into the global namespace

  2. It declares the function within the current scope

  3. It makes the function virtual

  4. It hides all other functions with the same name outside the namespace

The correct answer is: It declares the function within the current scope

A using declaration for a function name within a namespace scope does not import the function into the global namespace (answer A). Instead, it allows the function to be called within the current namespace without needing to specify the full namespace path every time. Option C is incorrect because a using declaration does not make the function virtual. Option D is incorrect because it only hides functions with the same name in the same namespace, not outside of it.