title: Can not access private member variable in .h file from .cpp
body: <p>I am new to C++, and not sure why I cant access return type 
  from .cpp that is defined in .h file. When I change Edge::Vertex getVertex1() to Vertex getVertex1() I only get error<br>
  error: use of undeclared identifier 'vertex1' (the same for vertex 2 in edge class)
  Can someone explain why this approach is not good?</p>
  
  <pre><code>// Graph.cpp -- Graph contains main function.
  #include &lt;iostream&gt;
  #include &lt;list&gt;
  #include &lt;string&gt;
  #include "Vertex.h"
  #include "Edge.h"
  #define EDGE_DISTANCE 1 
  using namespace std;
  class Graph
  {        
  };
  
  int main()
  {
     Vertex v1(0);
     Vertex v2(1);
     Edge edge(v1, v2);
  
     // cout &lt;&lt; edge.getVertex1() &lt;&lt; endl;
     // cout &lt;&lt; edge.getVertex2() &lt;&lt; endl;
  
     return 0;
  }
  --------------------------------------------------------------
  // Edge.h
  #ifndef EDGE_H
  #define EDGE_H
  #include "Vertex.h"
  using namespace std;
  
  class Edge
  {
      private:
          Vertex vertex1;
          Vertex vertex2;
          int weight;
      public:
         Edge(Vertex,Vertex);
         Vertex getVertex1();
         Vertex getVertex2();
  };
  #endif
  --------------------------------------------------------------
  // Edge.cpp
  #include "Edge.h"
  Edge::Edge(Vertex _vertex1, Vertex _vertex2)
  {
     vertex1 = _vertex1;
     vertex2 = _vertex2;
     weight  = 1;
  }
  
  Edge::Vertex getVertex1() // error: no type named 'Vertex' in 'Edge'
  {
     return vertex1;        // error: use of undeclared identifier 'vertex1'    
  }
  
  Edge::Vertex getVertex2()
  {
    return vertex2;
  }
  --------------------------------------------------------------
  // Vertex.h
  #ifndef VERTEX_H
  #define VERTEX_H
  #include &lt;list&gt;
  using namespace std;
  
  class Vertex
  {
    private:
        long id;
  
    public:
        list&lt;Vertex&gt; adjacentVertexes;
        Vertex();
        Vertex(long);
  };
  #endif
  --------------------------------------------------------------
  // Vertex.cpp
  #include "Vertex.h"
  Vertex::Vertex(long _id)
  {
     id = _id;
  }
  </code></pre>