how to write "insert" in vector?
<p>I write this,but it didn't work...</p>

<pre><code>template&lt;typename T&gt;
typename vector&lt;T&gt;::iterator vector&lt;T&gt;::insert(iterator pos,const T&amp; val)
{
    int a=0,b=0;
    if(capacity()==0) a=capacity()+1;
    if(capacity()==size())
    {
        a=capacity()*2;
        T *start2=operator new[](a*sizeof(T)))
        for(int i=0;;i++)
        {
             new(start2+i) T(start+i);
             if(start2+i==pos)
             {
                 b=start2+i;
                 break;
             }
        }
        start2+pos=val;
        for(int j=b;j&lt;=2*size();j++)
        {
             new(start2+j) T(start+j+1);
        }
    }
    else if(capacity()&gt;size())
    {
        for(int i=0;i&lt;=capacity();i++)
        {
            if(start+i==pos)pos=
        }
    }     
}
</code></pre>
