What's wrong with this declaration? Syntax error

Hey guys,

Getting a weird syntax error. Can't put my finger on why. I have a struct TreeNode that holds a string and 2 pointers. I'm trying to write a function that returns a pointer to a TreeNode, but I'm being told that there's something wrong with the function declaration.

Here's the code:

1
2
3
4
TreeNode * WordTree::findNode(string input){
    TreeNode ralph;
    return ralph
}



And the error:


1 expected constructor, destructor, or type conversion before '*' token
1 expected `,' or `;' before '*' token


Here's the way I declare it in the header under private:

 
TreeNode * findNode(string input);


For greater context, here's the code surrounding that code (note: when I comment out the findNode() function the whole thing compiles without a problem):

1
2
3
4
5
6
7
8
9
10
11
12
void WordTree::remove(string){
    int monkey;    
}

TreeNode * WordTree::findNode(string input){
    TreeNode ralph;
    return ralph;
}

void WordTree::removeNode(TreeNode * node){
    int monkey;
}



Anyone know why I'm getting this syntax error?

Much thanks,
Try making ralph a TreeNode pointer, not just a TreeNode.
Oops, silly mistake on my part.

Still getting the same error, though.
Ok, I found the issue. It's because TreeNode was declared as a member of the class WordTree, so I had to declare the function like so:

1
2
3
4
WordTree::TreeNode * WordTree::findNode(string input){
    TreeNode *  ralph;
    return ralph;
}
Topic archived. No new replies allowed.