How to call method with parameter of type vector<int>::iterator& in C++?
<p>I have a method to find number in range of iterator like below. I want it has reference parameter and return reference of iterator.</p>

<pre><code>// find number in range of begin and end, if number found return reference of iterator, throw exception otherwise
vector&lt;int&gt;::iterator &amp;find_int(vector&lt;int&gt;::iterator &amp;begin, vector&lt;int&gt;::iterator &amp;end, int &amp;number)
{
    for (; begin != end; ++begin)
    {
        if (*begin == number)
        {
            return begin;
        }
    }

    throw "not found";
}
</code></pre>

<p>I want to call this method as following code but it can't compile.</p>

<pre><code>vector&lt;int&gt;::iterator i5 = find_int(vi1.begin(), vi1.end(), 5);
</code></pre>

<p>I want to know how can I call <code>find_int</code> method ?</p>

<p><strong>Update</strong>
Error message when compile the code</p>

<pre><code>C:\Windows\system32\cmd.exe /c g++ c:\cpp\ch9.cpp -o c:\cpp\ch9.exe
c:\cpp\ch9.cpp: In function 'int main()':
c:\cpp\ch9.cpp:41:63: error: invalid initialization of non-const reference of ty
pe 'std::vector&lt;int&gt;::iterator&amp; {aka __gnu_cxx::__normal_iterator&lt;int*, std::vec
tor&lt;int&gt; &gt;&amp;}' from an rvalue of type 'std::vector&lt;int&gt;::iterator {aka __gnu_cxx:
:__normal_iterator&lt;int*, std::vector&lt;int&gt; &gt;}'
c:\cpp\ch9.cpp:30:24: error: in passing argument 1 of 'std::vector&lt;int&gt;::iterato
r&amp; find_int(std::vector&lt;int&gt;::iterator&amp;, std::vector&lt;int&gt;::iterator&amp;, int&amp;)'
shell returned 1
Hit any key to close this window...
</code></pre>
