title: when defining a private structure in a class how do i use it as a function parameter or return type?
body: <p>I have created a graph.h, graph.cpp, and main.cpp
  In my graphics.h I've created two private structures an Edge
  and a Node, and I've declared Edge first above Node but an 
  Edge has a node member so I've forward declared the Node struct
  but I'm running into issues saying a "Graph::Node*" is incompatible
  with "Node *" this occurs in my graph.cpp AddEdgeByName(string,string,double)
  function, why does this happen? On top of this I dont know why I had to declare in (graphics.cpp) the function Graph::Node * Graph::findByName(string name) like that I thought the way i originally tried to declare it like this
  Node * Graph::findByName(string name) would work but it gave me an error.
  Im trying to make a Directed weighted graph by the way.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  
  
  using std::cout;
  using std::cin;
  using std::endl;
  using std::string;
  using std::vector;
  
  struct Node;
  
  class Graph{
  
      private:
          typedef struct edge{
              double edgeWeight;
              Node *pointsTo;
  
              edge(){}
              edge(const edge &amp; copyObject){
                  this-&gt;edgeWeight = copyObject.edgeWeight;
                  this-&gt;pointsTo = copyObject.pointsTo;
              }
  
          } Edge;
  
          typedef struct node{
              string name;
              vector&lt;Edge&gt; myEdges;// list of outgoing edges for this node
  
              node(string myName){
                  name = myName;
              }
  
              node(const node &amp; copyObject){
                  this-&gt;name = copyObject.name;
                  this-&gt;myEdges = copyObject.myEdges;
              }
              // adds another edge to this node
              void addEdge(Node *pointTo, double weight){
                  Edge newEdge;
                  newEdge.edgeWeight = weight;
                  newEdge.pointsTo = 
                  newEdge.pointsTo = pointTo;
                  myEdges.push_back(newEdge);
              }
          } Node;
  
          vector&lt;Node*&gt; graph; // vector containing all the nodes for the
                               //graph
      public:
          Graph();
          // finds a node in the list of nodes for the graph, using the name
          Node * findByName(string name);
  
          void add(string name);
  
          void addEdgeByName(string first, string second,double weight);
  
  
  };
  
  #endif
  
  
  
  
  // this is graphics.cpp
  
  #include "Graph.h"
  
  
  Graph::Graph(){
  
  
  
  }
  
  Graph::Node * Graph::findByName(string name){
  
  
  
      for(std::vector&lt;Node*&gt;::iterator it = graph.begin(); it != graph.end(); ++it){
  
          if((*it)-&gt;name == name){
              return *it;
          }
      }
      return NULL;
  }
  
  void Graph::add(string name){
  
      Node * newNode = new Node(name); // creates a new node with the given                 //name
      graph.push_back(newNode); // adds this node to our list of nodes in the //graph
  }
  
  // this publicly accessible function adds edges to each of the strings
  
  void Graph::addEdgeByName(string first, string second,double weight){
  
      Node * firstNode = findByName(first);
      Node * secondNode = findByName(second);
      firstNode-&gt;addEdge(secondNode,weight);
      secondNode-&gt;addEdge(firstNode,weight);
  
  }
  </code></pre>