template <class T> class Tree
{
protected:
//--------------------------------------------------------
// inner class Node
// a single Node from a binary tree
//--------------------------------------------------------
template <class T> class Node
{
public:
Node * left;
Node * right;
T value;
Node(T val)
: value(val), left(NULL), right(NULL){}
Node(T val, Node<T> * l, Node<T> * r)
: value(val), left(l), right(r){}
}; //end of Node class
Node<T> * root;
public:
Tree() {root=NULL;} // initialize tree
};
template <class T>
class SearchTree : public Tree<T>
{
public:
// protocol for search trees
void add(T value);
bool search(T value) {return search(root,value); }
void remove(T value);
Node<T>* minimum(){return minimum(root); }
Node<T>* findSuccessor(Node<T>* x);
Node<T>* findParent(T val);
private:
void add(Node<T> * current, T val);
bool search(Node<T>* current, T val);
Node<T>* minimum(Node<T>* current);
};
// THE ERROR IS HERE
template <class T>
Node<T>* searchTree<T>::minimum(Node<T>* current);
{
while (current->left != NULL)
curent= current->left;
return current;
}
**我想這樣做,將返回節點, 的指針,我認爲一個功能,因爲它的模板害我一個錯誤, 做我有另一種方式來實現該功能?**錯誤C2143:語法錯誤:缺少';'之前,「<」
你應該標記BЈовић或Blaze的答案是正確的。 – KomodoDave 2012-07-08 14:07:35