?
2009-06-10 10:51:12 UTC
---
Tree.h:92: error: expected constructor, destructor, or type conversion before â*â token
---
But I can't find anything syntactically wrong with the code. I don't think that the error has anything to do with the code above or below it either, because when I delete it, everything complies fine.
Below is the function definition:
---
091 : template
092 : Node* Tree
093 : - if(node == 0)
094 : - - return 0;
095 :
096 : - int result = compare(node->key_, key);
097 :
098 : - if(result == 0)
099 : - - return node;
100 : - else if(result == -1)
101 : - - return findNodeRecursively(node->left_, key);
102 : - else
103 : - - return findNodeRecursively(node->right_, key);
104 :}
---
The class deceleration is:
---
template
class Tree {
- public:
- Tree(int (*compare)(K, K));
- //~Tree();
- void insertValue(K key, V* value);
- V* findValue(K key);
- void deleteValue(K key);
- int getDepth() const; // 1-based
- void debug() const;
private:
- class Node {
- public:
- - Node(K key, V* value) : key_(key), value_(value) { }
- - K key_;
- - V* value_;
- - Node* left_;
- - Node* right_;
- };
- void insertRecursively(Node* node, K key, V* value);
- Node* findNodeRecursively(Node* node, K key);
- int getDepthRecursively(Node* node) const;
- Node* root_;
- int (*compare_)(K, K);
};
---
I'm new to C++, so feel free to critique as well :)