How to get position of a certain element in strings vector, to use it as an index in ints vector?
<p>I am trying to get the index of an element in a vector of strings, to use it as an index in another vector of int type, is this possible ?</p>

<p>example: </p>

<pre><code>vector &lt;string&gt; Names;
vector &lt;int&gt; Numbers;

 .. 
if(( find(Names.begin(), Names.end(), old_name_)) != Names.end())  // condition to        check whether the name exists or no
    { // if yes
            cout &lt;&lt; "Enter the new name."&lt;&lt;endl;
            cin &gt;&gt; name;
            replace(Names.begin(), Names.end(), old_name_, name );

    }
</code></pre>

<p>now I want to get the position of old_name in the Names vector, to use it in accessing certain element in Numbers vector. so that I can say :</p>

<pre><code>Numbers[position] = 3 ; // or whatever value assigned here.
</code></pre>

<p>I tried using :</p>

<pre><code>vector &lt;string&gt; :: const_iterator pos;
pos = ( find(Names.begin(), Names.end(), old_name_))
Numbers[pos] = 3;
</code></pre>

<p>but obviously this doesn't work since pos is of type string !</p>
