title: initializing a vector of custom class in c++
body: <p>Hey basically Im trying to store a "solution" and create a vector of these. The problem I'm having is with initialization. Heres my class for reference</p>
  
  <pre><code>class Solution
  {
  private:
        //  boost::thread m_Thread;
          int itt_found;
          int dim;
          pfn_fitness f;
          double value;
          std::vector&lt;double&gt; x;
  public:
  
          Solution(size_t size, int funcNo) : itt_found(0), x(size, 0.0), value(0.0), dim(30), f(Eval_Functions[funcNo])
          {
              for (int i = 1; i &lt; (int) size; i++) {
                  x[i] = ((double)rand()/((double)RAND_MAX))*maxs[funcNo];
              }
          }
  
          Solution() : itt_found(0), x(31, 0.0), value(0.0), dim(30), f(Eval_Functions[1])
          {
              for (int i = 1; i &lt; 31; i++) {
                  x[i] = ((double)rand()/((double)RAND_MAX))*maxs[1];
              }
          } 
          Solution operator= (Solution S) 
          {
              x = S.GetX();
              itt_found = S.GetIttFound();
              dim = S.GetDim();
              f = S.GetFunc();
              value = S.GetValue();
              return *this;
          }
          void start()
          {
              value = f (dim, x);
          }
          /* plus additional getter/setter methods*/
  }
  </code></pre>
  
  <p><code>Solution S(30, 1)</code> or <code>Solution(2, 5)</code> work and initalizes everything, but I need X of these solution objects. <code>std::vector&lt;Solution&gt; Parents(X)</code> will create X solutions with the default constructor and i want to construct using the (int, int) constructor. Is there any easy(one liner?) way to do this? Or would i have to do something like:</p>
  
  <pre><code>size_t numparents = 10;
  vector&lt;Solution&gt; Parents;
      Parents.reserve(numparents);
      for (int i = 0; i&lt;(int)numparents; i++) {
          Solution S(31, 0);
          Parents.push_back(S);
      }
  </code></pre>