title: C++ "Access violation reading location" Error
body: <p>I have the following <code>Vertex</code> struct in a <code>Graph</code> class:</p>
  
  <pre><code>struct Vertex
  {
      string country;
      string city;
      double lon;
      double lat;
      vector&lt;edge&gt; *adj;
  
      Vertex(string country, string city, double lon, double lat)
      {
          this-&gt;country = country;
          this-&gt;city = city;
          this-&gt;lon = lon;
          this-&gt;lat = lat;
          this-&gt;adj = new vector&lt;edge&gt;();
      }
  };
  </code></pre>
  
  <p>When calling the method I've written called <code>getCost()</code>, I keep getting the same Unhandled Exception </p>
  
  <blockquote>
    <p>Access violation reading location 0x00000048</p>
  </blockquote>
  
  <p>and I cannot figure out why. </p>
  
  <p>the <code>getCost()</code> method:</p>
  
  <pre><code>void Graph::getCost(string from, string to)
  {
  
      Vertex *f = (findvertex(from));
      vector&lt;edge&gt; *v = f-&gt;adj;     // Here is where it gives the error
      vector&lt;edge&gt;::iterator itr = v-&gt;begin();
  
      for (; itr != v-&gt;end(); itr++)
      {
          if (((*itr).dest)-&gt;city == to)
              cout &lt;&lt; "\nCost:-" &lt;&lt; (*itr).cost;
      }
  }
  </code></pre>
  
  <p>The method <code>findvertex()</code> returns a value of type <code>Vertex*</code>. Why do I keep receiving this error?</p>
  
  <p>the findVertex method:</p>
  
  <pre><code>Vertex* Graph::findvertex(string s)
  {
      vmap::iterator itr = map1.begin();
      while (itr != map1.end())
      {
          if (itr-&gt;first == s){
  
              return itr-&gt;second;
          }
          itr++;
      }
      return NULL;
  }
  </code></pre>
  
  <p>Where <code>map1</code> is defined:</p>
  
  <pre><code>typedef map&lt; string, Vertex *, less&lt;string&gt; &gt; vmap;
  vmap map1;
  </code></pre>