title: C++ forbids declaration of 'binaryTreeType' with no type
body: <p>I've tried moving this code around all over and I cannot get past this compile error. I need to pass the binaryTreeType into the constructor for PostorderTreeEnum because the root pointer is protected and I cannot change that or access it any other way. Any insite on how to declare the type? I have tried putting the BinaryTreeType header and methods first but that doesn't fix it either. Any help will be much appreciated!!!!</p>
  
  <pre><code>#ifndef H_binaryTree
  #define H_binaryTree
  
  #include &lt;iostream&gt;
  #include &lt;stack&gt;
  
  using namespace std;
  
       //Definition of the node
  template&lt;class elemType&gt;
  struct nodeType
  {
     elemType info;
     nodeType&lt;elemType&gt; *llink;
     nodeType&lt;elemType&gt; *rlink;
  };
  
  template&lt;class elemType&gt;
  class PostorderTreeEnumerator
  {
  public:
  PostorderTreeEnumerator(const binaryTreeType&lt;elemType&gt; *&amp;otherTree);
  
  elemType nextElement();
  
  bool hasMoreElements();
  
  void slideLeft();
  
  void reset();
  
  //friend class binaryTreeType&lt;elemType&gt;;
  
  private:
  stack&lt;nodeType&lt;elemType&gt;* &gt; st;
  
  
  };
  
  template&lt;class elemType&gt;
  PostorderTreeEnumerator&lt;elemType&gt;::PostorderTreeEnumerator(const binaryTreeType&lt;elemType&gt; *&amp;otherTree)
  {
      slideLeft(this -&gt; root);
  }
  
  template&lt;class elemType&gt;
  elemType PostorderTreeEnumerator&lt;elemType&gt;::nextElement()
  {
      nodeType&lt;elemType&gt; *current, parent;
      st.pop(&amp;current);
  
      if (!st.isEmpty())
      {
         st.pop(parent);
         if(parent -&gt; rlink != current)
          slideleft(parent -&gt; rlink); 
      }  
  }
  
  template&lt;class elemType&gt;
  bool PostorderTreeEnumerator&lt;elemType&gt;::hasMoreElements()
  {
      return st.isEmpty();
  }
  
  template&lt;class elemType&gt;
  void PostorderTreeEnumerator&lt;elemType&gt;::slideLeft()
  {
    nodeType&lt;elemType&gt; *current;
    current = this -&gt; root;
  
    while(current != NULL)
    {  
      st.push(current);
      current = current-&gt;llink;
    }
    if(st.isEmpty())
      return;
    st.pop(current);
    if(current-&gt;rlink != NULL)
      slideleft(current-&gt;rlink);
  }
  
  template&lt;class elemType&gt;
  void PostorderTreeEnumerator&lt;elemType&gt;::reset()
  {
  
  }
  
      //Definition of the class
  template &lt;class elemType&gt;
  class binaryTreeType
  {
  public:
      const binaryTreeType&lt;elemType&gt;&amp; operator=
                   (const binaryTreeType&lt;elemType&gt;&amp;);
        //Overload the assignment operator.
      bool isEmpty();
        //Function to determine if the binary tree is empty.
        //Postcondition: Returns true if the binary tree is empty;
        // otherwise, returns false.
      void inorderTraversal();
        //Function to do an inorder traversal of the binary tree.
        //Postcondition: The nodes of the binary tree are output
        // in the inorder sequence.
      void preorderTraversal();
        //Function to do a preorder traversal of the binary tree.
        //Postcondition: The nodes of the binary tree are output
        // in the preorder sequence.
      void postorderTraversal();
        //Function to do a postorder traversal of the binary tree.
        //Postcondition: The nodes of the binary tree are output
        // in the postorder sequence.
  
      int treeHeight();
        //Function to deteremine the height of the binary tree.
        //Postcondition: The height of the binary tree is returned.
      int treeNodeCount();
        //Function to determine the number of nodes in the
        //binary tree.
        //Postcondition: The number of nodes in the binary tree
        // is returned.
      int treeLeavesCount();
        //Function to determine the number of leaves in the
        //binary tree.
        //Postcondition: The number of leaves in the binary tree
        // is returned.
      void destroyTree();
        //Deallocates the memory space occupied by the binary tree.
        //Postcondition: root = NULL;
  
  void nonRecursiveInTraversal();
  void nonRecursivePreTraversal();
  void nonRecursivePostTraversal();
  
      binaryTreeType(const binaryTreeType&lt;elemType&gt;&amp; otherTree);
        //copy constructor
  
      binaryTreeType();
        //default constructor
  
      ~binaryTreeType();
        //destructor
  
  void createTree1();
  
  void inorderTraversal(void (*visit) (elemType&amp;));
  //Function to do an inorder traversal of the binary tree.
  //The parameter visit, which is a function, specifies
  //the action to be taken at each node.
  
  PostorderTreeEnumerator&lt;elemType&gt; getPostorderEnumerator();
  
  friend class PostorderTreeEnumerator&lt;elemType&gt;;
  
  
  protected:
      nodeType&lt;elemType&gt; *root;
  
  private:
      void copyTree(nodeType&lt;elemType&gt;* &amp;copiedTreeRoot,
                    nodeType&lt;elemType&gt;* otherTreeRoot);
        //Function to make a copy of the binary tree to
        //which otherTreeRoot points.
        //Postcondition: The pointer copiedTreeRoot points to
        // the root of the copied binary tree.
  
      void destroy(nodeType&lt;elemType&gt;* &amp;p);
        //Function to destroy the binary tree to which p points.
        //Postcondition: The nodes of the binary tree to which
        // p points are deallocated.
        // p = NULL.
  
      void inorder(nodeType&lt;elemType&gt; *p);
        //Function to do an inorder traversal of the binary
        //tree to which p points.
        //Postcondition: The nodes of the binary tree to which p
        // points are output in the inorder sequence.
      void preorder(nodeType&lt;elemType&gt; *p);
        //Function to do a preorder traversal of the binary
        //tree to which p points.
        //Postcondition: The nodes of the binary tree to which p
        // points are output in the preorder sequence.
      void postorder(nodeType&lt;elemType&gt; *p);
        //Function to do a postorder traversal of the binary
        //tree to which p points.
        //Postcondition: The nodes of the binary tree to which p
        // points are output in the postorder sequence.
  
      int height(nodeType&lt;elemType&gt; *p);
        //Function to determine the height of the binary tree
        //to which p points.
        //Postcondition: The height of the binary tree to which p
        // points is returned.
  
      int max(int x, int y);
        //Function to determine the larger of x and y.
        //Postcondition: The larger of x and y is returned.
  
      int nodeCount(nodeType&lt;elemType&gt; *p);
        //Function to determine the number of nodes in the binary
        //tree to which p points.
        //Postcondition: The number of nodes in the binary tree
        // to which p points is returned.
  
      int leavesCount(nodeType&lt;elemType&gt; *p);
        //Function to determine the number of leaves in the binary
        //tree to which p points.
        //Postcondition: The number of nodes in the binary tree
        // to which p points is returned.
  
  void inorder(nodeType&lt;elemType&gt; *p, void (*visit) (elemType&amp;));
  //Function to do an inorder traversal of the binary
  //tree, starting at the node specified by the parameter p.
  //The parameter visit, which is a function, specifies the
  //action to be taken at each node.
  
  PostorderTreeEnumerator&lt;elemType&gt; *postTreeEnum;
  };
  
  
  
  template&lt;class elemType&gt;
  PostorderTreeEnumerator&lt;elemType&gt; binaryTreeType&lt;elemType&gt;::getPostorderEnumerator()
  {
  return postTreeEnum;
  }
  </code></pre>
  
  <p>Here is the compilation error from sublime.</p>
  
  <pre><code>/Users/jason/dev/CS271/Lab9/binaryTree.h:24: error: expected ',' or '...' before '&lt;' token
  /Users/jason/dev/CS271/Lab9/binaryTree.h:24: error: ISO C++ forbids declaration of         'binaryTreeType' with no type
  /Users/jason/dev/CS271/Lab9/binaryTree.h:43: error: expected ',' or '...' before '&lt;' token
  /Users/jason/dev/CS271/Lab9/binaryTree.h:43: error: ISO C++ forbids declaration of     'binaryTreeType' with no type
  [Finished in 1.0s with exit code 1]
  </code></pre>