What is the purpose of a namespace in C++?

17 views
  • To allow functions to have the same name without causing conflicts.
  • To allow classes to have the same name without causing conflicts.
  • To allow variables to have the same name without causing conflicts.
  • All of the above. (Correct Answer)

Explanation

Correct answer: d) All of the above.

Explanation: A namespace in C++ is a declarative region that provides a scope for identifiers (such as functions, classes, and variables) to prevent naming conflicts. It allows multiple entities to have the same name as long as they are declared in different namespaces.

Comments (0)

No comments yet. Be the first to comment!

Want to practice more?

Explore thousands of MCQs across every exam category on Exams Nepal.

Find More MCQs