|
namespace { } |
proftilley
Member #697
October 2000
|
I never saw this in school; I never saw this in a book; this "namespace" syntax. |
vpenquerch
Member #233
April 2000
|
it is used to avoid putting every global in the main name space. |
SystemDown
Member #663
September 2000
|
The namespace clause allows you to be able to place the code for certain modules under a name, for example the standard C++ classes, functions, types & templates (STL) are all under the 'std' namespace.
--- |
SystemDown
Member #663
September 2000
|
Heh, beaten to the line by Vincent.
--- |
Mars
Member #971
February 2001
|
quote:in "blah.h", you would put all your definitions and such under the namespace blah {} clause quote:I think I tried specifying my own namespace under DJGPP in the past, but it didn't work. Not sure about the latest version though You can also say If you have a namespace without a name, then it's contents do not collide with anything else -> It's a way to hide the things in the namespace. -- |
Gabhonga
Member #1,247
February 2001
|
hmm...do namespaces bring any other "benefit", like the optimizer doing a better job or something like that? I had bothered about keeping stuff in namespaces first, too (like global vars and functions that do not fit into classes), though I found in in programming practice to be just more typing-work...well, maybe the benefit comes from clearer source organization when doing teamwork, and as I'm working on my sources alone I know where everything is anyway and just don't bother about namespaces anymore...but maybe I should? -------------------------------------------------------- |
proftilley
Member #697
October 2000
|
Thanks guys. This has been truly helpful. |
SystemDown
Member #663
September 2000
|
Thanks for picking up my error Mars (the one about declarations and not definitions), in hindsight, I would've indeed said the right thing had I been more awake at the time.
--- |
Mars
Member #971
February 2001
|
Whoops, you're rigth, systemdown. but at least you have understood me. Btw is there any case where one would write "it's" and not "its"? -- |
Mars
Member #971
February 2001
|
To answer my question myself: to say "it is" or "it has". Doh! -- |
vpenquerch
Member #233
April 2000
|
i can't see anything that an optimizer could use to generate better code, as namespaces are essentially a way of structuring scope. |
SystemDown
Member #663
September 2000
|
Mars: yeah you're correct, "it's" is the short form of "it is" or "it has". But it wasn't always like that...
--- |
Mars
Member #971
February 2001
|
Languages are not logical. -- |
|