This is an example of a template that can be used to translate enumeration values into strings (which will usually be a string version of the enumeration name). These enumerations can be packaged within a class, which avoids making the enumeration identifiers global.
The template is EnumTranslate
Two example classes are included, class Fruit and class Numbers. These classes define local enumeration sets and instantiate the EnumTranslate template.
Each instance of the template has its own static table used to translate between enumeration values and C strings.
You may use this source code without limitation and without fee as long as you include:
This software was written and is copyrighted by Ian Kaplan, Bear Products International, www.bearcave.com, 2001, 2002.
This software is provided "as is", without any warrenty or claim as to its usefulness. Anyone who uses this source code uses it at their own risk. Nor is any support provided by Ian Kaplan and Bear Products International.