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.