title: Passing vector iterator to a function c++
body: <p>Can anyone explain to me why the following segment compiles but the commented line after doesn't?</p>
  
  <pre><code>struct tObj
  {
      int data;
      int moreData;
  }
  
  ...
  
  void funcToCall (tObj *obj, int moreData)
  {
      //Useful stuff here
  }
  
  void mainFunction ()
  {
      vector&lt;tObj&gt;::iterator it = vectorOfObjects.begin(); //assumes vectorOfObjects is already defined
      while (it != vectorOfObjects.end())
      {
          funcToCall (&amp;(*it), 0); //This line works
          funcToCall (it, 0); //This line produces an error
          it++;
      }
  }
  </code></pre>
  
  <p>The error produced is this:</p>
  
  <pre><code>error: cannot convert ‘std::vector&lt;tObj&gt;::iterator {aka __gnu_cxx::__normal_iterator&lt;tObj*, std::vector&lt;tObj&gt; &gt;}’ to ‘tObj*’
  </code></pre>
  
  <p>Any ideas on why <code>&amp;(*it)</code> works but just plain <code>it</code> doesn't? Logically they are the same, aren't they?</p>
  
  <p>Because doesn't <code>*</code> mean to dereference and <code>&amp;</code> mean pass by reference aka cancelling each other out?</p>