Why does the compiler swear when I return a pointer to an object of an inner class in an outer method? Suppose we have a template class like this:
template <class T> class BST { int sizeBST; int fun_count; private: class node { public: int key; T data; int bal; node *left, *right; node(int, T); ~node(); } *head; public:BST(); node *min(node *); } So, after describing the node min (node ) method and compiling, the compiler swears, as in error C2143: syntax error : missing ';' before '*'. error C2143: syntax error : missing ';' before '*'. approximate description of the method:
template <class T> node * BST <T>::min(node * elem) { if (elem != NULL) { while (1) { if (elem->left != NULL) elem = elem->left; else return elem; } } return NULL; }; The method must find the minimum node according to the key in the tree from the incoming pointer and return a pointer to the found one or NULL if there is none. What's the matter?
VC ++ compiler.