I'm trying to create a recurring struct method in my code to walk through a binary search tree. But I'm getting errors on compile and unsure what is the cause.
I've got Node* findNode(const Node *, const Object &);
in the private section of the .h file
and
Node* BSTree::findNode(const Node* current, const Object &target){
if(*current->item == target)
return current;
Node* temp = NULL;
if(current->nodeLeft != NULL){
temp = findNode(current->nodeLeft, target);
if(temp != NULL)
return temp;
}
if(current->nodeRight != NULL){
temp = findNode(current->nodeRight, target);
if(temp != NULL)
return temp;
}
return NULL;
}
in the cpp.
I'm generating the following errors:
-error C2143: syntax error : missing ';' before '*'
-error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
-error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
-error C2556: 'int *BSTree::findNode(const BSTree::Node *,const Object &)' : overloaded function differs only by return type from 'BSTree::Node *BSTree::findNode(const BSTree::Node *,const Object &)'
The compiler errors are all pointing at the first line of the code in the cpp. I tried looking up the error codes, but I didn't find anything that answered my question as to the cause.
What is causing the errors and why is my compiler reading it at 'int BSTree' not Node* BSTree? Am I making a syntax error or forgetting an include? Currently I just have included iostream and fstream.
My thanks in advance for anyone who takes the time to read this.
Edit:
To answer Colin's question.
I have #include "BSTree.h" in my .cpp
And in the .h I have:
#ifndef BSTREE_H
#define BSTREE_H
#include <iostream>
#include <fstream>