AVLNode
isn't a template; it's a regular class nested within a template. So within the template, just use the class name:
AVLNode *lookup(const T &key);
and outside the template, qualify it with the template's scope:
template <class T>
AVLTree<T>::AVLNode* AVLTree<T>::lookup(const T &key)
{
}
You'll also need to fix the definition of AVLNode
; you're currently declaring Node
to be a data member of AVLTree
(which you don't want), and attempt to define a type AVLNode
to be an alias for Node
(which won't compile since Node
isn't a type). Just define a class type, with no data members or typedefs:
struct AVLNode
{
AVLNode *left;
AVLNode *right;
AVLNode *parent;
int balanceFactor;
};
As noted in the comments, templates (including member functions of class templates) usually need to be defined in a header, as the definition must be available wherever it's used.
You'll also need to make sure the definitions are in the correct namespace, and qualify the template name appropriately (MYTree::AVLNode
) when you're not in that namespace.
AVLTree<int> tree();
declares a function; remove the ()
to create a default-initialised object.
Finally, don't do using namespace std;
in the global namespace, as it can lead to confusing name conflicts.