The following is a simple sample of using a CList. This sample is kept especially simple by making it a list of integers. The first thing to do is to make a typedef, as in:
typedef CList <int, int> CListType;
Next, use the typedef as in the following:
CListType List;
Then add entries as in (where "i" is an "int"):
List.AddTail(i);
Then iterate through the list as in the following:
int i; POSITION Position = List.GetHeadPosition(); while (Position) i = List.GetNext(Position);
Finally, remove all the elements as in:
List.RemoveAll;
Notice that since since we are not storing pointers, there is not any clean-up necessary.
See my Visual C++ Programmer Stuff page for more C++ stuff.