title: binary '[' : no operator found which takes a left-hand operand of type 'const std::map<_Kty,_Ty>'
body: <p>I don't know where the error is coming from. It seems like I'm passing valid data into the [ ] operator. </p>
  
  <pre><code>template &lt;class VertexType&gt;
  typename map&lt; Vertex&lt;VertexType&gt;, int &gt;::iterator Graph&lt;VertexType&gt;::findEdge( const VertexType&amp; v, const VertexType&amp; w ) const
  {
      map&lt;Vertex&lt;VertexType&gt;, int&gt;::const_iterator iter = vertices[v].second.adjList.find(w);
  
      return iter;
  }  // end findEdge  
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const std::map&lt;_Kty,_Ty&gt;' (or there is no acceptable conversion)
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=unsigned int,
  1&gt;              _Ty=Vertex&lt;unsigned int&gt;
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\map(164): could be 'Vertex&lt;VertexType&gt; &amp;std::map&lt;_Kty,_Ty&gt;::operator [](unsigned int &amp;&amp;)'
  1&gt;          with
  1&gt;          [
  1&gt;              VertexType=unsigned int,
  1&gt;              _Kty=unsigned int,
  1&gt;              _Ty=Vertex&lt;unsigned int&gt;
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\map(209): or       'Vertex&lt;VertexType&gt; &amp;std::map&lt;_Kty,_Ty&gt;::operator [](const unsigned int &amp;)'
  1&gt;          with
  1&gt;          [
  1&gt;              VertexType=unsigned int,
  1&gt;              _Kty=unsigned int,
  1&gt;              _Ty=Vertex&lt;unsigned int&gt;
  1&gt;          ]
  1&gt;          while trying to match the argument list '(const std::map&lt;_Kty,_Ty&gt;, const unsigned int)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=unsigned int,
  1&gt;              _Ty=Vertex&lt;unsigned int&gt;
  1&gt;          ]
  1&gt;          c:\users\user\desktop\cs m20a\topic g project 2\topic g project 2\graph.h(146) : while compiling class template member function 'std::_Tree_iterator&lt;_Mytree&gt; Graph&lt;VertexType&gt;::findEdge(const VertexType &amp;,const VertexType &amp;) const'
  1&gt;          with
  1&gt;          [
  1&gt;              _Mytree=std::_Tree_val&lt;std::_Tmap_traits&lt;Vertex&lt;unsigned int&gt;,int,std::less&lt;Vertex&lt;unsigned int&gt;&gt;,std::allocator&lt;std::pair&lt;const Vertex&lt;unsigned int&gt;,int&gt;&gt;,false&gt;&gt;,
  1&gt;              VertexType=unsigned int
  1&gt;          ]
  1&gt;          c:\users\user\desktop\cs m20a\topic g project 2\topic g project 2\graph.h(52) : while compiling class template member function 'Graph&lt;VertexType&gt;::Graph(unsigned int)'
  1&gt;          with
  1&gt;          [
  1&gt;              VertexType=unsigned int
  1&gt;          ]
  1&gt;          c:\users\user\desktop\cs m20a\topic g project 2\topic g project 2\topicg.cpp(17) : see reference to class template instantiation 'Graph&lt;VertexType&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              VertexType=unsigned int
  1&gt;          ]
  </code></pre>
  
  <p>And the <code>Graph</code> class:</p>
  
  <pre><code>template &lt;class VertexType&gt;
  class Graph
  {
  private:
       // list of all vertices in the graph. assumes non-duplicate data.
      map&lt; VertexType, Vertex&lt;VertexType&gt; &gt; vertices;
  
      const unsigned MAX_VERTICES;  // Maximum number of vertices the graph can hold.
      unsigned numVertices;         /** Current number of vertices in the graph. */
      unsigned numEdges;            /** Number of edges in the graph. */
  
      typename map&lt; Vertex&lt;VertexType&gt;, int &gt;::iterator findEdge( const VertexType&amp; v, const VertexType&amp; w ) const;  
  
  public:
     Graph( unsigned max );
  
     unsigned getNumVertices() const;
     unsigned getMaxNumVertices() const;
     unsigned getNumEdges() const;
     int getWeight( const VertexType&amp; v, const VertexType&amp; w ) const;
  
     Graph&lt;VertexType&gt;&amp; addVertex( const VertexType&amp; newValue );
     Graph&lt;VertexType&gt;&amp; addEdge( const VertexType&amp; v, const VertexType&amp; w, int weight );
     void removeEdge( const VertexType&amp; v, const VertexType&amp; w );
     void BFS( const VertexType&amp; v ) const;
     void display() const;
  }; // end Graph
  </code></pre>