Jump to content
  • Advertisement

Archived

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

Convict@Large

set as class member

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

I am still learning STL so bare with me here if this is simple question: Is this the correct way to declare a set as a class member?
  
// define int type

typedef signed int S32;

class TestClass
{
   set<S32, less<S32> >m_TestSet;
};
  
Cheers, Convict@Large

Share this post


Link to post
Share on other sites
Advertisement
Yes, although since this is probably in a header file I''d be inclined to not have a using directive, and instead do:

std::set<S32> m_TestSet;

Otherwise, inclusion of the header file will pollute the global namespace. Also, note that you don''t need to specify less<> as the sort predicate, since that is the default.

Share this post


Link to post
Share on other sites
excellant thanks for the quick reply. My stl book did not mention about use of stl stuff inside class''es.

Cheers,

Convict@Large

"I code therefore I am" Anon

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!