Listing 2 The GroupList class
namespace SynSoft { namespace Security { // GroupList.h /// Represents a list of groups public __gc class GroupList : public IEnumerable , public IDisposable { public: GroupList(int cGroups, SID_AND_ATTRIBUTES *groups); // IDisposable public: void Close(); void Dispose(); // IEnumerable public: IEnumerator *GetEnumerator(); // Members private: ArrayList *m_groups; }; // GroupList.cpp GroupList::GroupList(int cGroups, SID_AND_ATTRIBUTES *groups) : m_groups(new ArrayList(cGroups)) { for(int i = 0; i < cGroups; ++i) { m_groups->Add(new Group(new SID(groups[i].Sid), groups[i].Attributes)); } } void GroupList::Close() { if(0 != m_groups) { dispose_contents(m_groups); m_groups->Clear(); m_groups = 0; } } } }