DesignPatterns_Iterator


// 1. Making sure iterators get deleted. Notice that CreateIterator returns a 
// newly allocated iterator object. We're responsible for deleting it. If
// we forget, then we've created storage leak. To make life easier for client,
// we'll provide an IteratorPtr that acts as a proxy for an iterator. It takes
// care of cleaning up the Iterator object when it goes out of scope.
// 2. IteratorPtr is always allocated on the stack. C++ automatically takes care
// of calling its destructor, which deletes the real iterator. 


你可能感兴趣的:(DesignPatterns_Iterator)