title: Initializing a vector on a class constructor
body: <p>I'm doing this A class which has a vector of B's. I'm initializing the vector on the constructor of the A class (I'm not sure if this is the right way, but it compiles). Besides this, I'm having a problem because I don't want that when initializing the vector that it initializes himself with the default construtor of B() because this makes me do a for loop to set the value that I want. It would be fine if the vector position stood NULL or stood 0 to size;    </p>
  
  <pre><code>class B{
      int _t;
  public:
      B(){ _t = 1; }
      B(int t) : _t(t){}
   };
  
  
  
  class A{
      std::vector&lt;B&gt; _b;
  public:
      A(int size): _b(size){
          for(int i = 0; i &lt; size; i++){
          _b[i].setNumber(i);
      }
  };  
  
  
  int main() {
      int n = 3;
      A _a(n);
      return 0;
  }
  </code></pre>