title: How to initialize a vector in C++
body: <p>I want to initialize a vector like we do in case of an array.</p>
  
  <p>Example</p>
  
  <pre><code>int vv[2] = {12, 43};
  </code></pre>
  
  <p>But when I do it like this,</p>
  
  <pre><code>vector&lt;int&gt; v(2) = {34, 23};
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>vector&lt;int&gt; v(2);
  v = {0, 9};
  </code></pre>
  
  <p>it gives an error:</p>
  
  <blockquote>
    <p>expected primary-expression before ‘{’ token</p>
  </blockquote>
  
  <p>AND</p>
  
  <blockquote>
    <p>error: expected ‘,’ or ‘;’ before ‘=’ token</p>
  </blockquote>
  
  <p>respectively.</p>