title: Returning a reference of an object inside a vector
body: <p>Suppose I have the following:</p>
  
  <pre><code>class Map
  {
      std::vector&lt;Continent&gt; continents;
  
  public:
  
      Map();
      ~Map();
      Continent* getContinent(std::string name);
  };
  
  Continent* Map::getContinent(std::string name)
  {
      Continent * c = nullptr;
      for (int i = 0; i &lt; continents.size(); i++)
      {
          if (continents[i].getName() == name)
          {
              c = &amp;continents[i];
              break;
          }
      }
  
      return c;
  }
  </code></pre>
  
  <p>You can see here that there are <code>continent</code> objects that live inside the <code>vector</code> called <code>continents</code>. Would this be a correct way of getting the object's reference, or is there a better approach to this? Is there an underlying issue with vector which would cause this to misbehave? </p>