Skip to main content

8.4) A Useful Abbreviation Technique: The typedef


Iterator types can have lengthy names which are tedious to type if you are defining iterators frequently in your code.

In such cases, you can define a new, abbreviated name for the iterator type like so:

typedef vector<double>::iterator iter;

After this, iter can be used as shorthand for the iterator type.

Use this technique sparingly; overusing it can make your code harder to read!