title: How could I assign values to c++ vector
body: <p>I know that I can initialize a vector like this: </p>
  
  <pre><code>vector&lt;int&gt; v{1,3,4,6};
  </code></pre>
  
  <p>However, when I define a class which contains a vector, I cannot initialize it in the position that I declare it, like this:</p>
  
  <pre><code>class C {
    public: 
      vector&lt;int&gt; v; 
      C();
  };
  </code></pre>
  
  <p>Thus I need to initialize it in the construction function. The following code works, but is not clean: </p>
  
  <pre><code>C::C() {
      v.resize(4); 
      v[0]=1; 
      v[1]=3; 
      v[2]=4; 
      v[3]=6;
  }
  </code></pre>
  
  <p>How could I initialize it neatly and directly like <code>vector&lt;int&gt; v{1,3,4,6};</code> rather than assign values one by one ?</p>
  
  <p>Edit: 
  Maybe I have not make my situation clear. The value of {1,3,4 6} may not be predefined values, they would depend on some logic and conditions: <code>if(condition_a) {v[0] = 0; v[1]=3; ...} else {v[0]=4;v[0]=8;...}</code>. Thus I have to deal with some other things to know how to initialize this vector, so I cannot use initialization list as suggested in some answers. Any advice please?</p>