|
-
Jun 21st, 2001, 10:24 PM
#1
What is the namespace?
I have a Borland compiler from about 2 years ago, and have only recently started learning C++. The book I have continually has the line using namespace std; at the top, and i don't know what it does. Whenever i include this line i get an error, so I take it out and it works fine. am i doing something wrong, or is my compiler too old to know what this means? does it really matter if I can't use the namespace feature at all?
-
Jun 22nd, 2001, 12:26 AM
#2
Do you know how to work with classes? If you ever have, youll notice that every class member function has a "SomeClass::" in front of it. This just tells the computer that this function belongs to this class. The same goes for namespaces, but, instead of "SomeClass::SomeFunction" its "SomeNamespace::SomeClass::SomeFunction". What namespaces are generally used for is like, if your company had a set of standard classes where the names might conflict with other classes by other companies, etc, your classes would look like "MyCompany::blahblah::blah", while the others were like "OtherCompany::blahblah::blah". Make sense?
So, in answer to your question, no, you really dont have to know how to use namespaces, but its a good thing to know how they work. I think all of the Standard template library classes are in the std namepace, so say, you wanted to use an STL Vector class, you would define the variable like this "std::vector<int> myIntVector;". Hopefully I'm making sense =).
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|