Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Oct 9, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

The Rationale Behind Namespaces

Some users consider the addition of namespaces to C++ as superfluous or even harmful. In order to understand why namespaces were added to the language, imagine that the file system on your PC / Mainframe didn't have any directories and subdirectories. All files would be stored in a flat repository, which would be visible to every user and application at all times. Consequently, you would run into extreme difficulties. Filenames would clash (with some systems limiting a filename to 8 characters + 3 for the extension, this is likely to happen); simple actions like listing, copying or searching files would be much more difficult; and security and authorization restrictions would be severely compromised.

Namespaces in C++ are equivalent to directories. They can be nested easily, they protect you from name clashes, they allow you to hide declarations simply by not using a namespace, and they do not incur any runtime or memory overhead.

Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date