You’ve probably used Visual Basic’s Collection class, but you might not understand exactly what it is. Let’s take a look behind the curtain.
To put it simply, the Collection class is a souped-up C++ version of the CList class described in “A List of Link Objects,” page 170. In fact, if you enhance CList to be a doubly linked list and give it a few more features (and perhaps use a hash table to look up string keys), you’ll have a collection class much like the one provided with Visual Basic. You could even add the code required to make it iterate with For Each.
But before we get to the part about writing your own enumeration classes, let’s review some of the tried and true features of the Collection class.