title: Using a class' constructor within a vector of the same type in C++
body: <p>Consider:</p>
  
  <pre><code>MyClass {
      //constructor
      MyClass()
      {}
  .
  .
  .
  };
  </code></pre>
  
  <p>Then, defining a vector of the same type</p>
  
  <pre><code>int main()
  {
  .
  .
      vector&lt;MyClass&gt;myVector(12);
  .
  .
  </code></pre>
  
  <p>Is this allowed?</p>
  
  <pre><code>for(int i = 0; i &lt; myVector.size(); i++)
  {
      //an attempt to fill my vector with initialized MyClass objects.
      myVector[i] = MyClass(); //Calling constructor
  }
  </code></pre>
  
  <p>OR:
  (in the case of not defining a vector's size)</p>
  
  <pre><code>for(int i = 0; i &lt; whatever; i++)
  {
      //an attempt to fill my vector with initialized MyClass objects.
      myVector.push_back(MyClass()); //Calling constructor
  }
  </code></pre>
  
  <p>If this is not allowed, what is an alternative for initializing class instances and storing them in a vector without using pointers? Is there such a thing?</p>