What is the purpose of a namespace?

I got a question in a challenge of C++: (Both opponents at 4-4) What is the purpose of a namespace? //By some Ben 1) access a library 2) naming a file But here, both answers are wrong as the use of a namepace is not this, and the std library is accessed using 'using'! A namespace is for scoping particular data... Eg: A's program and B's code... So, I lost 32 xp thanks to this. The question now is, how can SoloLearn approve this? Why reject my questions if you can approve incorrect ones? Help me...

4/21/2017 9:19:49 AM

Kinshuk Vasisht

8 Answers

New Answer


The question should be What is the purpose of "using namespace ..."? Then the answer will be 1. access a library.


They disapproved this: https://www.sololearn.com/discuss/330835/?ref=app


I know, but tell me, are those answers correct?


@Cyrus Ornob Corraya Yes, thats what it should be...


@Raletooane Yes, thats what namespaces are for... How can the creator of that quiz forget this?


Try again and again. There are lots of quizzes to be made. Just think, write and submit. Some might get approved. Have faith and patience.


Nope! None of those are correct. Report that question/quiz.


Namespaces provide a method for preventing name conflicts in large projects. Symbols declared inside a namespace block are placed in a named scope that prevents them from being mistaken for identically-named symbols in other scopes. Multiple namespace blocks with the same name are allowed. All declarations within those blocks are declared in the named scope. //cppreference.com