Archived

This topic is now archived and is closed to further replies.

Namespaces

This topic is 6394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok... It seems that this is (almost) the last concept of OOP that I haven''t learnt yet. It seems they are useful, but still I haven''t found them in the many books I used (they only refer to them, but doesn''t explain them). So here are my questions: What are namespace? How to implement them? Sources, examples, etc. What are the plus and minus of Namespace? What do they do exactly? How can they help in a program? In a game? In an analysis of a program or a game? Thanks in advance.
Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).

Share this post


Link to post
Share on other sites
I''m not 100% sure, but I think namespace is used to make a block code private like in a class. This way, you can use the same name in global space without name-clashes. Afterwards you can refer to any of them via namespace:: orso...?

Share this post


Link to post
Share on other sites
mmmmh...
thanks Baskuenen.

Hey! We are often "discussing"[1] together

I don''t think your explanations were enough, but at least you answered something, not like the others who knows. I think I will make a search on it.


[1] Sharing points...

Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).

Share this post


Link to post
Share on other sites
That is my take on it as well. I think you can be 100% sure now

Namespaces separate functions, variables (I think classes) from the global namespace (the place where all global variable names are).

You can do something like this:
    
namespace MyNamespace
{
int NamespaceVariable;
}

// you can access it like this, just like a static function in a class
MyNamespace::NamespaceVariable = 0;

// or you can do this, to bring it into the global namespace (basically undoes the namespace)
using namespace MyNamespace;
NamespaceVariable = 0;


--------------------


You are not a real programmer until you end all your sentences with semicolons;

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

Share this post


Link to post
Share on other sites
It doesn''t affect memory in speed, then. Just accessing different variables. I mean, in assembly it will be the same, just different addresses, is that it?

Thanks. Now I really know what it is Thanks Baskuenen, you were nearer than I thought...

Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).

Share this post


Link to post
Share on other sites