Namespaces
Moderator: Coders of Rage
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Namespaces
What is the purpose of a namespace, and why use it? I know there's namespace std in the STL, and Nehe's new tutorials have a namespace nehe, but what do you actually use it for?
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Namespaces
A namespace is basically making things neat... it's a container if you will...
The namespace you are in is just a way to keep all your classes organized under something bigger.
Commands are in a function, functions are in classes, classes are in a namespace.
The namespace you are in is just a way to keep all your classes organized under something bigger.
Commands are in a function, functions are in classes, classes are in a namespace.
There's no place like ~/
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Namespaces
If you're working on a large project it prevents function/class name overlap, theoretically, too. I've never used one in a C++ project, although I use them in C# on separate modules with namespaces of "Appname.Business" (contains classes that do calculations on data), "Appname.Data" (contains classes that interface with database), "Appname.Utility" (contains secure redirect fn)...
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: Namespaces
The namespace concept appears in order to control the scope of names to allow the same names to be used without conflicts - Text from the book "Programming in c++"
My english sucks!
Re: Namespaces
Namespaces are used to avoid name clashes between existing libraries, and anything you might write (in its most basic use).
I've seen it used in a modular programming paradigm as well.
I've seen it used in a modular programming paradigm as well.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Namespaces
I thought that might have been what it was... Thanks for clarifying.BOMBERMAN wrote:The namespace concept appears in order to control the scope of names to allow the same names to be used without conflicts - Text from the book "Programming in c++"
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.