title: Inheritance and AVL/BST Trees
body: <p>Is there any way to use the same insert function for both Bst and Avl tree? The problem is that Bst and Avl have different Node types, but I don't want to make the Bst Node a general case(with height and Node* parent inside, which makes no sense because there is no need of parent and height inside a Bst).</p>
  
  <pre><code>class Bst
  {
  public:
      struct Node
      {
          int value;
          Node* left;
          Node* right;
      };
  
      Node* insert(Node* node) {/* do stuff using Bst::Node */}
  
      // ...
  };
  
  class Avl : public Bst
  {
  public:
      struct Node : public Bst::Node
      {
          int height;
          Node* parent;
      };
  
      // now I want that Bst::insert use this Node
      // instead of the old one
  
  
      Node* insert(Node* node)
      {
          Node* inserted_node = Bst::insert(node);
          /* rotations stuff */
          return inserted_node;
      }
  };
  </code></pre>
  
  <p>Roughly what I'm trying to do is make <code>Bst::Node "virtual"</code>.</p>
  
  <p>So, how can I solve the problem of implenting the Avl Tree without rewriting the entire insert function just because Node changed?</p>