I have never previously used any namespace other than std, however I have been reading about them and I don't understand where they come from. Everywhere I read about them there is no mention of how the compiler gets them. Does a namespace need to be defined in a separate file or does the compiler already have them? If so how would I go about using say my computer science professor's namespace? It seems he just includes it in his code and expects us to use it, but I don't see how the compiler would automatically be familiar with the namespace.
To use the classes and functions declared in that namespace,
You need to include the header file where he used it.
and then attach a prefix:
your_profs_ns::
to the stuff declared there.
namespace myns
{
void SomeFunction();
}
// then you can use the namespace:
int main()
{
myns::SomeFunction();
// or if you prefer
usingnamespace myns;
SomeFunction();
}