title: C++ new types definition via typedef
body: <p>I am a newbie in C++ and I have encountered a problem that I need to define a new data types (unions concretely) via typedef in my class. The relevant code snippet of .h module of my class is following</p>
  
  <pre><code>class Manager
  {
  
    public:
  
      static const uint8_t NO_BYTES_IN_PACKET;
      static const uint8_t NO_PYLD_BYTES_IN_CONTROL_PACKET;
  
      // control packet structure
      typedef union{
          struct{
              uint8_t header[3];                                
              uint8_t payload[NO_PYLD_BYTES_IN_CONTROL_PACKET];  
          }pkt_parts_t;
          uint8_t pkt_array[NO_BYTES_IN_PACKET];
      }control_pkt_u;
  
    private:
  
  }
  </code></pre>
  
  <p>My problem is that the constants</p>
  
  <pre><code>static const uint8_t NO_BYTES_IN_PACKET;
  static const uint8_t NO_PYLD_BYTES_IN_CONTROL_PACKET;
  </code></pre>
  
  <p>are defined in associated .cpp module</p>
  
  <pre><code>const uint8_t Manager::NO_BYTES_IN_PACKET = 8;
  const uint8_t Manager::NO_PYLD_BYTES_IN_CONTROL_PACKET = 5;
  </code></pre>
  
  <p>Due to that I have been receiving an error message: <strong>error: array bound is not an integer constant before ']' token</strong> during compilation process. My idea was to move the union definition into the .cpp module but I am not sure whether it is correct approach. What are your opinions? Thank you for any ideas. </p>