I am gettin this compile error and for the life of me cannot figure it out:
BinarySearchTree.h:22: error: type âintâ is not a direct base of âBinarySearchTree<int, int, std::less<int> >::BinaryNodeâ
This is the header file file the error refers:
#ifndef BINARY_SEARCH_TREE_H
#define BINARY_SEARCH_TREE_H
#include <cstdlib>
#include <functional>
template <class T, class Key = T, class Compare = std::less<Key> >
class BinarySearchTree
{
public:
BinarySearchTree();
void InsertSorted(const T& data);
void InsertSorted(const Key& key, const T& data);
private:
struct BinaryNode
{
T data;
Key key;
BinaryNode *left;
BinaryNode *right;
BinaryNode(Key k, T i) : data(i), Key(k) {left = NULL; right = NULL;}
};
BinaryNode *root;
Compare compare;
void InsertSortedR(const Key& key, const T& data, BinaryNode*& node);
};
#include "BinarySearchTree.cpp"
#endif
Do I have too many assignments in the struct constructor?