I'm working on a binary search tree class and implementing a Find operation. There are two versions of the public function, one which returns a const Node* and is const and the other which returns a non-const Node* and is not itself const. Here are the public definitions:
const Node *Find(const T &t) const { Find(t, m_root); }
Node *Find(const T &t) { Find(t, m_root); }
And here's the definition of the private Find method:
template <typename T>
const Node* CTree<T>::Find(const T &t, Node *root) const {
if (root == 0)
return Node();
else if (t < root->m_number)
Find(t, root->m_ll);
else if (t > root->m_number)
Find(t, root->m_rl);
else
return this;
}
Visual Studio is telling me that "'Find' : member function not declared in 'CTree'". Why would it say that?
Edit to add specifics of error messages:
There are 5 messages for the line of the private method definition starting const Node*...
Missing type specifier - int assumed
Syntax error : missing ';' before '*'
'T' : undeclared identifier
'CTree' : 'T' is not a valid template type argument for parameter 'T'
syntax error : missing ',' before '&'
Then one more error for the closing brace of the definition (this is the one that I believe is causing the other 5):
'Find' : member function not declared in 'CTree'
As a note, Visual Studio is not highlighting Node
in the definition of Find
as it does elsewhere.
Here's the whole class: http://pastebin.com/JEEZJD4n