here are the .h and .cpp files. im stumped, can't get this very annoying warning to go away.
BinarySearch.h
Code:
#include <iostream.h>
#include <string.h>
#include <cstddef>
#include <fstream.h>
class TreeNode
{
public:
TreeNode() {}
TreeNode(const TreeNode& treeNodeObject);
TreeNode(string nodeItem,
TreeNode *left = NULL,
TreeNode *right = NULL):
data(nodeItem),leftLink(left),
rightLink(right){}
friend class BST;
private:
string data;
TreeNode *leftLink, *rightLink;
};//end TreeNode class
class BST
{
public:
// constructors and deconstructors
BST() : root(NULL) {}
virtual ~BST();
//BST operations
void insert(string newItem);
bool check(string newItem) const;
void retrieve(string key, string& treeItem) const;
void inorder() const;
private:
void insert(string newItem, TreeNode *& subTreeRoot);
void deleteSubTree(TreeNode *& subTreeRoot);
bool check(string newItem, TreeNode *subTreeRoot) const;
void inorder(TreeNode *subTreeRoot) const;
TreeNode *root;
}; //end BST class
BinarySearch.cpp
Code:
#include "BinarySearch.h"
void BST::insert(string item, TreeNode *& subTreeRoot)
{
if (subTreeRoot == NULL)
subTreeRoot = new TreeNode (item, NULL, NULL);
else if (item < subTreeRoot->data)
insert(item, subTreeRoot->leftLink);
else
insert(item, subTreeRoot->rightLink);
}
void BST::insert(string item)
{
insert (item, root);
}
bool BST::check(string item, TreeNode *subTreeRoot) const
{
if (subTreeRoot == NULL)
return false;
else if (subTreeRoot->data == item)
return true;
else if (item < subTreeRoot->data)
return check(item, subTreeRoot->leftLink);
else
return check(item, subTreeRoot->rightLink);
}
bool BST::check(string item) const
{
return check(item, root);
}
void BST::inorder(TreeNode *subTreeRoot) const
{
if (subTreeRoot != NULL)
{
inorder(subTreeRoot->leftLink);
inorder(subTreeRoot->rightLink);
}
}
void BST::inorder() const
{
inorder(root);
}
void BST::deleteSubTree(TreeNode *& subTreeRoot)
{
if (subTreeRoot != NULL)
{
deleteSubTree(subTreeRoot->leftLink);
deleteSubTree(subTreeRoot->rightLink);
delete subTreeRoot;
subTreeRoot = NULL;
}
}
BST::~BST()
{
deleteSubTree(root);
}
//void BST::deleteItem