Well to start let me say that I'm only a newbie, as my status says, but after a year of C++ I have what I consider a pretty good grasp over the basics of the language. I'm still at school for the summer doing an internship and have a lot of extra time so I'm making little applications for our CS department as well using openGL. My problem is not with this as I am able to create and implement whole applications that run well and everything, using classes and all the good elements of C++ OOP like virtual functions and abstract classes, but I'm trying to branch out a little more and discover more of the use of the language.
I realized that we have never really covered namespaces in class or outside of it. All of my projects reside in the humble std namespace and there's no problem with doing it that way, but I was wondering what exactly the use of auxillary namespaces is? The one example I've come up with myself is that it would allow the creation of two identically named variables and then a switching between namespaces to access the proper one depending on the context, but that seems like it would be more easily/simply done with an array. My question is actually two similar questions:
1) Why are namespaces used? What kind of programming makes them extremely useful, or are they used more for a "better" encapsulation than simple classes?
2) Why are namespaces included in the C++ language, specifically what do they "do" for the language?
Number two might be just a slightly different way of asking number 1, but any light more experienced people could shed on namespaces would be greatly appreciated.