>> What does the namespace std code do?
Namespaces prevent name clashes. So say you have a 'strcpy' function that takes the same arguments as the standard library's. Just wrap yours up in a custom namespace and - voila - an extra scoping facility, basically. There are three basic ways to use code from another namespace.
1) using namespace fumanchu;
That simply allows you to use any function from 'fumanchu::' without specifying it explicitly with the scope-resolution operator.
2) using fumanchu::strcpy;
That allows you to use that *one* function without the scope-resolution operator.
3) fumanchu::strcpy(str, "foo");
If either (1) or (2) were not done, this is how you must access any code from 'fumanchu::'. Explicitly.
"The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." - Donald Knuth
|