set as class member

Started by
1 comment, last by Convict@Large 22 years, 1 month ago
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
DanielB - Slayer of Bugs
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&ltS32> 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.
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
DanielB - Slayer of Bugs

This topic is closed to new replies.

Advertisement