title: C++ pure virtual class question
body: <p>I'm attempting to write a simple B+tree implementation (very early stages).  I've got a virtual class with a few functions.  Needless to say, I'm very new to these strategies and am running into all sorts of problems.</p>
  
  <p>I'm attempting to create a root node within the BTree class.  The root node will be a BBranch, which should inherit from BNode?  I'm getting errors </p>
  
  <pre><code>btree.cpp: In constructor âBTree::BTree()â:
  btree.cpp:25: error: cannot declare variable ârootâ to be of abstract type âBBranchâ
  btree.cpp:12: note:   because the following virtual functions are pure within âBBranchâ:
  btree.cpp:9: note:      virtual void BNode::del(int)
  btree.cpp: In member function âvoid BTree::ins(int)â:
  btree.cpp:44: error: ârootâ was not declared in this scope
  </code></pre>
  
  <p>The code is this</p>
  
  <pre><code>using namespace std;
  
  class BNode {
    public:
      int key [10];
      int pointer [11];
      virtual void ins( int num ) =0;
      virtual void del( int num ) =0;
  };
  
  class BBranch: public BNode {
    public:
      void ins( int num );
  };
  
  class BLeaf: public BNode {
    public:
      void ins( int num );
  };
  
  class BTree {
    public:
      BTree() {
        BBranch root;
      };
      void ins( int num );
  };
  
  // Insert into branch node
  void BBranch::ins( int num ){
      // stuff for inserting specifically into branches
  
  };
  
  // Insert for node
  void BTree::ins( int num ){
    root.ins( num );
  };
  
  int main(void){
    return 0;
  }
  </code></pre>
  
  <p>Thank you for any information you can give me.</p>