title: How to get position of a certain element in strings vector, to use it as an index in ints vector?
body: <p>I am trying to get the index of an element in a vector of <code>strings</code>, to use it as an index in another vector of <code>int</code> type, is this possible ?</p>
  
  <p>Example: </p>
  
  <pre><code>vector &lt;string&gt; Names;
  vector &lt;int&gt; Numbers;
  
   ... 
  // condition to check whether the name exists or not
  if((find(Names.begin(), Names.end(), old_name_)) != Names.end())  
      {   // 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 <code>old_name</code> in the <code>Names</code> vector, to use it in accessing certain element in <code>Numbers</code> 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 <code>pos</code> is of type string !</p>