Jump to content
  • Advertisement
Sign in to follow this  
mike74

namespaces

This topic is 4721 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

Could someone tell me when the "namespace" keyword arrived on the C++ scene? I don't remember ever reading about it in any of my books. Also, I tried the following code in Microsoft's compiler: #include <set> void main(void) { set<int, less<int> > s; } It won't compile unless I change it to: #include <set> using namespace std; void main(void) { set<int, less<int> > s; } Just for my own curiosity, does anyone know how to get it to compile without writing "using namespace std;" I'm guessing that you need to reference the namespace the set class resides in, but I don't know what namespace it's in or how to find out. Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Advertisement
Correct me if i am wrong , but in C there was no such thing as name space , thus if your project had abc.h efg.h , and both declared a variable int var , which was used locally by their respective implementations , it would give an error during the compiling , namespaces were introduced in c++ to resolve such trivial naming confilicts

Share this post


Link to post
Share on other sites
Quote:
Original post by Nokturnal
Correct me if i am wrong , but in C there was no such thing as name space

True. Namespaces were introduced in C++.

Share this post


Link to post
Share on other sites
Quote:

std::set<int, std::less<int> > s;


This isn't necessary as the default type parameter for the comparator type is std::less<T>, so std::set<int> is fine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!