User Profile

Collapse

Profile Sidebar

Collapse
theBNich
theBNich
Last Activity: Dec 12 '09, 07:46 PM
Joined: Nov 4 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • theBNich
    replied to Initializing static arrays with enum indices
    in C
    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...
    See more | Go to post

    Leave a comment:


  • theBNich
    started a topic Initializing static arrays with enum indices
    in C

    Initializing static arrays with enum indices

    Hi, I currently have an enumeration in class Lexer:

    Code:
    enum lexType {
    
        /* token keywords */
        lexIF, lexTHEN, lexWHILE, lexDO, lexBEGIN, lexEND, lexELSE, lexPROGRAM,
    
        ...
    
        /* used for array iterations */
        lexENUMSIZE
    };
    I have an array used to get the string representations of these types:

    Code:
    const char* lexTypeNames[lexENUMSIZE
    ...
    See more | Go to post
No activity results to display
Show More
Working...