+ 13
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...
8 Answers
+ 8
The question should be
What is the purpose of "using namespace ..."?
Then the answer will be 1. access a library.
+ 11
They disapproved this:
https://www.sololearn.com/discuss/330835/?ref=app
+ 9
I know, but tell me, are those answers correct?
+ 8
@Cyrus Ornob Corraya
Yes, thats what it should be...
+ 8
@Raletooane
Yes, thats what namespaces are for...
How can the creator of that quiz forget this?
+ 6
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.
+ 6
Nope! None of those are correct. Report that question/quiz.
+ 2
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