getting object in each element in vector
<p>Is there a way for an iterator to return an object in each element of a C++ Standard Library vector?</p>

<p>I have this code:</p>

<pre><code>struct mystruct {
  int field1;
}

int DoSomethingWithMyStruct(mystruct&amp; a);

std::vector&lt;mystruct&gt; myVector;
std::vector&lt;mystruct&gt;::iterator it;

mystruct s1,s2, temp;
s1.field1=1;
s2.field1=2;

for (it=myVector.begin();it!=myVector.end();it++)
{
   //I want to call DoSomethingWithMyStruct, so I have to pass in mystruct object.
   //can I use iterator to get the object of each element in myVector without having to create a temporary mystruct object and pass it in?
   //I'm looking for an easier way than having to do this:
   temp.field1 = it-&gt;field1;
   DoSomethingWithMyStruct(temp);

}
</code></pre>
