One of the popular uses of the Standard Template Library (STL) in the C++ language is to manage a dynamic list of pointers. For example, if you have a rendering system for your game which works with a common base object that every drawable object is derived from.
If you were using STL, then typically you would create something like the following:
#include <iostream>
#include <list>using namespace std;
class IRenderObj
{
public:
float x;
float y;
float z;
};main()
{
list<IRenderObj*> drawList;
list<IRenderObj*>::iterator drawListIter;IRenderObj *a= new IRenderObj;
IRenderObj *b= new IRenderObj;
IRenderObj *c= new IRenderObj;a->x = 0.0f; a->y = 0.0f; a->z = 0.0f;
b->x = 0.0f; b->y = 1.0f; b->z = 0.0f;
c->x = 1.0f; c->y = 0.0f; c->z = -10.0f;drawList.push_back(a);
drawList.push_back(b);
drawList.push_back(c);for (drawListIter = drawList.begin();
drawListIter != drawList.end();
drawListIter++)
{
//draw, translate each vector
glTranslatef( (*drawListIter)->x, (*drawListIter)->y, (*drawListIter)->z );}
// Now Free pointers
for (drawListIter = drawList.begin();
drawListIter != drawList.end();
drawListIter++)
{
delete *drawListIter;
}drawList.clear(); // List is deleted.
}


