Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You won't be able to define an <code>enum</code> externally. In C++11 you can forward declare an <code>enum</code>, however:</p> <pre><code>enum class Items: char; </code></pre> <p>... and later define it:</p> <pre><code>enum class Items: char { PAC = 'C', GHOST = '@', FRUIT = 'o', POINTS = '.', WALL = '#', EMPTY = ' ', UNDEFINED = '+' }; </code></pre> <p>Note, however, that you can use the enumerator tags only where the definition was seen.</p> <p>Based on your comment about multiple definitions, you don't have include guards in your header and the same header gets included multiple times. That is, seems you could have a header something like this:</p> <pre><code>// items.h #ifndef INCLUDED_ITEMS #define INCLUDED_ITEMS enum Items { ... }; #endif </code></pre> <p>From the looks of it, you are trying to fold the representation of the game into into the definition of their names. That probably doesn't work too well, especially as they may change appearance (you might want to have <code>PAC</code> alternate between <code>C</code> and <code>O</code>, for example). Most likely the actual code will talk about these names and you'll have the in multiple places. Just use an <code>enum</code> to define the different items not defining any value for them and define their representation elsewhere:</p> <pre><code>enum Items { PAC, GHOST, FRUIT, POINTS, WALL, EMPTY, UNDEFINED }; extern char ItemDisplay[]; // elsewhere char ItemDisplay[] = { 'C', '@', 'o', '.', '#', ' ', '+' }; </code></pre> <p>... and then just use <code>ItemDisplay[item]</code> whenever you need to draw an <code>item</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload