Hi,
this is my first post on here so forgive me if my question or code is unclear.
I'm coding a binary search tree and I'm stuck on the overloaded ==operator.
//BSTCLASS.CPP
template <class ItemType>
void BstClass<ItemType>::rFindNode(node<ItemType>* trav,ItemType& item,node<ItemType>* rtTrav,
ItemType& rtItem, bool& equal)const
{
rFindNode(trav->left, trav->left->data, rtTrav->left, rtTrav->left->data, equal);
if(item.key == rtItem.key)//Get an error here".key has no struct/union
equal = true;
else
equal = false;
rFindNode(trav->right, trav->right->data, rtTrav->right, rtTrav->right->data, equal);
template <class ItemType>
bool BstClass<ItemType>::operator==(const BstClass<ItemType>& rtOp)const
{
bool equal;
rFindNode(root, root->data,rtOp.root, rtOp.root->data, equal);
return equal;
}
I know the rFindNode function doesn't need all those parameters
i was just trying different things to see if i could get it to work.
my ItemType definition is in the client code per template standards
//TestClient.CPP
#include <iostream>
typedef int KeyType;
struct ItemType
{
KeyType key;
char data;
};
#include "bstTreeClass.h"
using namespace std;
void Display(ItemType& j);
void main() ......
My problem is that i'm getting an error when trying to assess my .key fields, I'm unclear on how i can access them so i can test them for equality