title: Create a templated nested class cpp
body: <p>There are many similar posts, but none seem to answer my problem.
  I have a templated class (AvlTree), and I want to create under it a nested class AvlTree::Node.</p>
  
  <p>Because the nested class is heavy, I want to define and implement it in a seperate file. But somehow, it doesn't seem to work, and some error are thrown, mainly:</p>
  
  <p>error C2039: 'Node' : is not a member of 'AvlTree'</p>
  
  <p>I have added both *.h file. Maybe you can help me understand the issue:</p>
  
  <p>AvlTree.h</p>
  
  <pre><code>#ifndef AVL_TREE_H_
  #define AVL_TREE_H_
  
  #include &lt;cstdlib&gt;
  
  template&lt;class Key, class Value&gt;
  class AvlTree
  {
  public:
  AvlTree();
  ~AvlTree();
  
  int insert(Key * key, Value * value);
  Value * remove(Key * key);
  Value * find(Key * key);
  void print();
  int clear();
  
  int getHeight();
  bool isEmpty() { return _root == NULL; }
  
  private:
  class Node&lt;Key, Value&gt;;
  
  typename Node&lt;Key, Value&gt; * _root;
  int _height;
  };
  
  #endif /* AVL_TREE_H_ */
  </code></pre>
  
  <p>AvlTreeNode.h</p>
  
  <pre><code>#ifndef AVL_TREE_NODE_H_
  #define AVL_TREE_NODE_H_
  
  #include "AvlTree.h"
  
  template&lt;class Key, class Value&gt;
  class AvlTree&lt;Key,Value&gt;::Node
  {
  public:
  Node(Key * key, Value * value);
  ~Node();
  
  int insert(Key * key, Value * value);
  Value * remove(Key * key);
  Value * find(Key * key);
  void print();
  int clear();
  
  Value * getValue()      { return _value;    }
  int     getHeight()     { return _height;   }
  int     getBalance()    { return _balance;  }
  
  private:
  Key *   _key;
  Value * _value;
  Node *  _left;
  Node *  _right;
  Node *  _parent;
  int     _height;
  int     _balance;
  
  void rotateLeft();
  void rotateRight();
  void rotateLeftRight();
  void rotateRightLeft();
  };
  
  #endif /* AVL_TREE_NODE_H_ */
  </code></pre>
  
  <p>I know there are some line of code that are completely irrelevant, but I believe the full picture is always a little bit better.</p>
  
  <p>Thanks for any help!</p>