>I'm thinking that software engineering is not a field I should be looking into; I can't do a lot of
>the projects in the book without asking for help.
Programming is very hard. I think you're doing well, all things considered. Only a handful of the pros I know could solve this problem easily without asking for help or nicking a solution from somewhere.
>but the compiler does not like my use of enqueue() for pair
pair and make_pair already exist in the <utility> header. It looks like you're trying to declare your own pair type and use it with the standard make_pair function, which is unlikely to work since they're designed as a pair (haha! I made a funny). Ditch the pair that you defined and make sure that your queue stores a pair rather than just a node:
Code:
template<class T>
void BinSearchTree<T>::getIPL()
{
static int count = 0;
Queue<pair<BinSearchNode<T>*, int> > anotherQueue;
BinSearchNode<T> * n = root;
if(n != 0)
{
anotherQueue.enqueue(make_pair(n, 0));
while(!anotherQueue.empty())
{
pair<BinSearchNode<T>*, int> save = n.dequeue();
n = save.first; //doesn't recognize save
count += save.second;
if(n->left != 0)
{
anotherQueue.enqueue(make_pair(n->left, save.second+1));
}
if(n->right != 0)
{
anotherQueue.enqueue(make_pair(n->right, save.second+1));
}
}
}
else
{
count = 0;
}
cout << "This tree has an IPL of " << count << endl;
}