Thanks for the Singleton suggestion--I've implemented it, and it's a nice solution. However, I'm not sure I understand why to use vectors instead of arrays here.
In general, I do use vectors over arrays for the reasons you stated. In this case, however, I'm simply creating an array, mapping strings to each index, and then accessing each index without any further modifications to the array thereafter. How do vectors help...
User Profile
Collapse
-
Initializing static arrays with enum indices
Hi, I currently have an enumeration in class Lexer:
I have an array used to get the string representations of these types:Code:enum lexType { /* token keywords */ lexIF, lexTHEN, lexWHILE, lexDO, lexBEGIN, lexEND, lexELSE, lexPROGRAM, ... /* used for array iterations */ lexENUMSIZE };
...Code:const char* lexTypeNames[lexENUMSIZE
No activity results to display
Show More
Leave a comment: