title: how to define an extensible C++ enum system
body: <p>I have encounter a problem in my project on enums. 
  In EventDef.h, </p>
  
  <pre><code>enum EventDef {
      EVT1 = 0,
      EVT2,
      EVT3,
      EVT_NUM,
  }
  </code></pre>
  
  <p>In this way, I can extend the EventDef system in another header UIEventDef.h by </p>
  
  <pre><code>#include "EventDef.h"
  enum UIEventDef {
      UIEVT1 = EVT_NUM,
      UIEVT2,
      UIEVT3,
  }
  </code></pre>
  
  <p>But, there is a limitation that i can not do this in NetEvent.h the same way.</p>
  
  <pre><code>#include "EventDef.h"
  enum NetEventDef {
      NETEVT1 = EVT_NUM,
      NETEVT2,   //wrong: this will have the same value as UIEVT2
      NETEVT3,  
  }
  </code></pre>
  
  <p>Is there a better compile time solution in C++ such as templates that can help ?</p>