I'm trying to create a function that is going to return a struct I made, when I try to define the function the the node I'm trying to reference returns an error saying "identifier is undefined".
template <class T>
class SplayTree
{
private:
struct splayNode
{
T element;
splayNode *leftChild;
splayNode *rightChild;
size_t height;
splayNode(T ele, splayNode left, splayNode right, size_t h = 0)
: element{ele}, leftChild{left}, rightChild{right}, height { h }
};
splayNode * root;
void rotateLeft(splayNode * node);
void rotateRight(splayNode * node);
splayNode splay(splayNode * root, T element);
public:
void insert(T element);
void remove(T element);
bool find(T element);
std::vector<T> preOrderWalk() const;
std::vector<T> inOrderWalk() const;
std::vector<T> postOrderWalk() const;
T getMin();
T getMax();
T getRoot();
size_t size();
};
and the definition:
template <class T>
splayNode SplayTree<T>::splay(splayNode * node, T element)
{
if (root == nullptr || root->key == key)
{
return root;
}
if (key < root->key)
{
if (root->left == nullptr)
{
return root;
}
}
}
I've checked multiple other questions like this but its mostly code structure. But I'm pretty sure I structured this correctly.