Tuesday, August 25, 2009

Simple Semantic Context Brought to You By Typedef

You vote: Confusing as heck or extremely useful?

The typedef specifier in C++ allows you to add that little bit of context that may be missing from your variable's type.

The following statement tells us that our property is not just a collection of Strings, but a collection of Strings that represent first names. 

typedef vector<bstr> FirstNames;
FirstNames mtvFirstNames;

The variable name implies the additional type context to me, but hey... I'm a Java developer.
Is there some uber niche where this comes in really handy?

No comments:

Post a Comment