when I removed all the templates I am getting errors again. I followed what others recommend and my code looks like this:
Code:
class Btree{
// OVERVIEW: a binary tree that is not sorted
private:
struct node { //a container object
node *left; //if the direction is straight
node *right; //if a right turn is made
node *parent; // points to the parent
tile *t; // pointer to object of node
};
public:
node *root; //pointer to the root of the tree (NULL if empty)
node * insert (tile *parent, tile *child, int childNum);
//MODIFIES: this
//EFFECTS: creates a node that stores a pointer to the new child
// and returns the pointer to the node of the new child
// the integer child is either 0, for left child,
// or anything else for right child
// for the purposes of this project, all right turns
// are stored on the right subtree
tile * removeAll(node *root);
//EFFECTS: deletes all nodes from the tree. called in dtor
Btree(); //ctor
Btree(tile *o); //alternative ctor, sets root to o
~Btree(); //dtor
};
and the .cpp file has this now
Code:
Btree :: node * Btree ::insert(node *parent, tile *child, int childNum)
{
node *np = new node;
np-> t = child;
np->left = NULL;
np->right = NULL;
if (root == NULL){
root = np;
} else{
np->parent = parent;
if (childNum == 0)
parent->left = np;
else
parent->right = np;
}
return np;
}
with this compiler error:
btree.cpp:3: error: prototype for ‘Btree::node* Btree::insert(Btree::node*, tile*, int)’ does not match any in class ‘Btree’
btree.h:31: error: candidate is: Btree::node* Btree::insert(tile*, tile*, int)
any ideas?!