Typedef and Templates

Use typedef to simplify using templates. Consider this example from MFC:

CList<CPoint,CPoint> * pPtList; // pointer to list of CPoints

instead, use:

typedef CList<CPoint,CPoint> CPointList

CPointList *pPtList;

Why bother? Well, for one thing, it makes it easier to keep track of your template types. Also, if someone is reading your code and they don't understand templates, they have a better chance of figuring out the second example.

This is especially good when you have functions that take pointers to functions that return template types as arguments (did that make sense?).