<p>I have a function which searches an STL container then returns the iterator when it finds the position, however I am getting some funny error messages, can tell me what I am doing wrong?</p>

<p>Function:</p>

<pre><code>std::vector&lt; CClass &gt;::iterator CClass::SearchFunction( const std::string&amp; strField )
{
...

   return it;

...
}
</code></pre>

<p>Error:</p>

<pre><code>error C2664: 'std::_Vector_iterator&lt;_Ty,_Alloc&gt;::_Vector_iterator(const std::_Vector_iterator&lt;_Ty,_Alloc&gt; &amp;)' : cannot convert parameter 1 from 'std::_Vector_const_iterator&lt;_Ty,_Alloc&gt; *__w64 ' to 'const std::_Vector_iterator&lt;_Ty,_Alloc&gt; &amp;'
</code></pre>

Your search function is returning a const_iterator. You should either return the same type, i.e.
```
std::vector< CClass >::const_iterator
```
, or cast it to a
```
std::vector< CClass >::iterator
```
if you intend the caller to be able to modify the found item through the iterator.
EDIT: after seeing your update, it seems the problem is your iterator (it) has a different type than your function return. They should be the same.
```
```
std::vector< CClass >::iterator it;
```
```