title: How do you add a repeated field using Google's Protocol Buffer in C++?
body: <p>I have the below protocol buffer. Note that StockStatic is a repeated field.</p>
  
  <pre><code>message ServiceResponse
  {
      enum Type
      {
          REQUEST_FAILED = 1;
          STOCK_STATIC_SNAPSHOT = 2;
      }
  
      message StockStaticSnapshot
      {
          repeated StockStatic stock_static = 1;
      }
      required Type type = 1;
      optional StockStaticSnapshot stock_static_snapshot = 2;
  }
  
  message StockStatic
  {
      optional string sector      = 1;
      optional string subsector   = 2;
  }
  </code></pre>
  
  <p>I am filling out the StockStatic fields while iterating through a vector.</p>
  
  <pre><code>ServiceResponse.set_type(ServiceResponse_Type_STOCK_STATIC_SNAPSHOT);
  
  ServiceResponse_StockStaticSnapshot stockStaticSnapshot;
  
  for (vector&lt;stockStaticInfo&gt;::iterator it = m_staticStocks.begin(); it!= m_staticStocks.end(); ++it)
  {
      StockStatic* pStockStaticEntity = stockStaticSnapshot.add_stock_static();
  
      SetStockStaticProtoFields(*it, pStockStaticEntity); // sets sector and subsector field to pStockStaticEntity by reading the fields using (*it)
  }
  </code></pre>
  
  <p>But the above code is right only if StockStatic was an optional field and not a repeated field. My questions is what line of code am i missing to make it a repeated field?</p>