tgghaus.com
tgghaus.com
Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
 All Forums
 Combat PA Forums
 General Chit Chat
 Question to Krusty and other programmers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Admax88
Noobie! ;)

38 Posts

Posted - 03/01/2004 :  11:16:57  Show Profile  Reply with Quote
One concept I don't understand about programming are namespaces. What is a namespace? Could you explain them to me Krusty?

Admax88
Noobie! ;)

38 Posts

Posted - 03/01/2004 :  13:52:35  Show Profile  Reply with Quote
I just read about them in my book, but the book wasn't very clear, although I think I understand them.

Go to Top of Page

Krusty
Incredibly Wordy Bastard

1158 Posts

Posted - 03/01/2004 :  15:12:29  Show Profile  Reply with Quote
Hmm...don't really know how to describe it well, but here goes:

a namespace is a space of names

When you are using C++ and type using namespace std, that means that you are using stuff in the namespace that starts with std. If you didn't use that line, and you wanted to do something like a cin statement, you'd have to type something like std::cin.

cin and cout are both in the std namespace. The using command there lets you know you are using stuff in the std namespace and not any other namespace. There could be another cin and cout in foo::cin or something.

Ok, now for another example for namespaces:

namespace this{
int foo = 12
}

namespace that{
float foo = 6.1828
}

using namespace this
cout << foo

using namespace that
cout << foo

^^one of those would output 12 and the other would output 6.1828 because the namespace used is different in each.



Go to Top of Page

na85
Incredibly Wordy Bastard

1404 Posts

Posted - 03/01/2004 :  16:30:28  Show Profile  Visit na85's Homepage  Send na85 an ICQ Message  Reply with Quote
Sorry to butt into a thread that has nothing to do with me, but:

quote:
a namespace is a space of names


LOL. Really?

They call me Sodium
Go to Top of Page

Admax88
Noobie! ;)

38 Posts

Posted - 03/01/2004 :  16:31:34  Show Profile  Reply with Quote
YAY! It all makes sense now. I knew it was something like that but it just didn't seem to click. Thanks Krusty.

Go to Top of Page

Krusty
Incredibly Wordy Bastard

1158 Posts

Posted - 03/01/2004 :  19:12:36  Show Profile  Reply with Quote
VGRA

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
tgghaus.com © 2009 Integral Corporation Go To Top Of Page
Snitz Forums 2000