Why Vector's size() and capacity() is different after push_back()
<p>I just starting to learning vectors and little confused about <code>size()</code> and <code>capacity()</code>
I know little about both of them. But why in this program both are different? even <code>array(10)</code> is making room for 10 elements and initializing with 0. </p>

<p><strong>Before adding <code>array.push_back(5)</code></strong></p>

<p>So <code>array.size();</code> is 10 that is ok.</p>

<p>So <code>array.capacity();</code> is 10 that is ok.</p>

<p><strong>After adding <code>array.push_back(5)</code></strong></p>

<p>So <code>array.size();</code> is 11 that is ok <code>(already 10 time 0 is added and then push_back add one more element 5 )</code>.</p>

<p>So <code>array.capacity();</code> is 15 Why? <code>( is it reserving 5 blocks for one int? )</code>.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
int main(){
    std::vector&lt;int&gt; array(10); // make room for 10 elements and initialize with 0
    array.reserve(10);    // make room for 10 elements
    array.push_back(5);
    std::cout &lt;&lt; array.size() &lt;&lt; std::endl;
    std::cout &lt;&lt; array.capacity() &lt;&lt; std::endl;
    return 0;
}
</code></pre>