As programmers become more familiar with namespaces, common programming idioms will emerge. Here are some current guidelines:
• Use variables in a named namespace instead of using external global variables.
• Use variables in an unnamed namespace instead of using static global variables.
• If you develop a library of functions or classes, place them in a namespace. Indeed, C++ currently already calls for placing standard library functions in a namespace called
std. This extends to functions brought in from C. For example, the
math.c header file, which is C-compatible, doesn’t use namespaces, but the C++
cmath header file should place the various math library functions in the
• Use the
using directive only ...