i'm working on a school assigment with Binary search trees

im trying to find the localtion of the smallest key in the binary nodes
so i created a function that retutns the point location to the smallest element key

template <typename DataType, class KeyType>                         
BSTreeNode * BSTree<DataType, KeyType>::findMin (BSTreeNode *root) const       <----- LINE 50
{
	if(root == NULL)
		return NULL;
	if(root->left == NULL)
		return root;
	return findMin(root->left);
}

DataType is the objects datatype.. and keyType is the key associated with the data.

however the problem is where the * is in the function header. its giving me errors like this

Error 1 error C2143: syntax error : missing ';' before '*' \bstree.cpp 50
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int bstree.cpp 50
Error 3 error C2065: 'DataType' : undeclared identifier \bstree.cpp 50
Error 4 error C2065: 'KeyType' : undeclared identifier \bstree.cpp 50
Error 5 error C2143: syntax error : missing ';' before '*\bstree.cpp 50
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int \bstree.cpp 50
Error 7 error C2065: 'DataType' : undeclared identifier bstree.cpp 50
Error 8 error C2065: 'KeyType' : undeclared identifier bstree.cpp 50

BSTRee is the original class
bstreenode is a class in the class for each node

my header in the .h file is
BSTreeNode * findMin (BSTreeNode *root) const;


thanks a bunch for the help!

p.s
solved!
if there is solution would be great! i just didnt want to waste more time and decided to send in a pointer as 2nd paremeter and usng that insted of return type. thanks

I am sure that your BSTreeNode calss must be template class and you should provide the template argument to this as well.
like

BSTreeNode<DataType, KeyType>* BSTree<DataType, KeyType>::findMin (BSTreeNode<DataType, KeyType>* root) const {
// Implimentation ... 
}

.
otherwise provide the implementation of class BSTreeNode to identify the exact error.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.