title: Organizing static data in C++
body: <p>I'm working on some embedded software where there is some static information about "products". Since the information for a certain product never changes during execution I would like to initialize these data structures at compile time to save some space on the stack/heap.</p>
  
  <p>I made a <code>Product</code> class for the data, intending to make a huge array of all the products in the system and then do lookups in this structure, but I haven't figured out quite how to get it working. The arrays are giving me loads of trouble. Some psuedo code:</p>
  
  <pre><code>class Product {
      int m_price;
      int m_availability[]; // invalid, need to set a size
      ... etc
  
      // Constructor grabbing values for all members
      Product(int p, int a[], ...);
  }
  
  static const Product products[] = 
  {
      Product(99, {52,30,63, 49}, ...), // invalid syntax
      ...                    
  }                     
  </code></pre>
  
  <p>Is there a way to making something like this work? The only thing I can think of would be to organize by attribute and skip the whole <code>Product</code> object. I feel that would make the whole thing harder to understand and maintain though. </p>
  
  <p>Does anyone have any suggestions on how I might best organize this kind of data?</p>
  
  <p>Thank you.</p>