title: c++ compiler error class has no member named
body: <p>I have a class called Edge and a class called Vertex</p>
  
  <p>in my Edge class there is a reference to a Vertex called target. in Vertex I send in an Edge and try to change the target through the Edge but am having a compiler error of class Edge has no member named target.</p>
  
  <p>my Edge.h is </p>
  
  <pre><code>#include "Vertex.h"
  
  class Edge
  {
    public:
     Edge *data;
     Edge *next;
     Vertex *target;
  
     Edge();
     Edge(Edge *x);
     Edge(Vertex *x);
  
     void print();
  
  };
  </code></pre>
  
  <p>the error is caused by this code in Vertex.cpp </p>
  
  <pre><code>Vertex::Vertex(Edge *x)
  {
    name = x-&gt;target-&gt;name;
    next = x-&gt;target-&gt;next;
    mark = x-&gt;target-&gt;mark;
    previous = NULL;
    next = NULL;
  }
  </code></pre>
  
  <p>the exact error when i try to compile Vertex is</p>
  
  <pre><code> g++  -g -I.  -c -o Vertex.o Vertex.cpp
  In file included from Vertex.h:3,
                   from Vertex.cpp:3:
  Edge.h:10: error: ISO C++ forbids declaration of ‘Vertex’ with no type
  Edge.h:10: error: expected ‘;’ before ‘*’ token
  Edge.h:14: error: expected ‘)’ before ‘*’ token
  Vertex.cpp: In constructor ‘Vertex::Vertex(Edge*)’:
  Vertex.cpp:26: error: ‘class Edge’ has no member named ‘target’
  Vertex.cpp:27: error: ‘class Edge’ has no member named ‘target’
  Vertex.cpp:28: error: ‘class Edge’ has no member named ‘target’
  </code></pre>