Vector C++ , whats wrong with getting the 2nd element of vector
<p>I have a vector which is of the code</p>

<pre><code>Vector&lt;Vehicle&gt; list
Vehicle *v1;
</code></pre>

<p>I did the following</p>

<pre><code>string inVehicle;

cout &lt;&lt; "Enter Vehicle Type";
cin &gt;&gt; inVehicle;

*v1 = new Vehicle;
v1-&gt;setName(inVehicle);
</code></pre>

<p>so I do another code to </p>

<pre><code>cout &lt;&lt; v1[0].getName() &lt;&lt; endl;
</code></pre>

<p>The result is okay, but if I add another value, as my cin Enter vehicle type is a switch case with while infinite till user key 5 to exit from program, it will keep working.</p>

<p>So I enter my 2nd entry, but when I try </p>

<pre><code>cout &lt;&lt; v1[1].getName() &lt;&lt; endl;
</code></pre>

<p>The second record, it doesnt work. IT is blank, but if I cout v1.size() , it display as 2</p>

<p>How do I get the 2nd element record normally and working?</p>
