Hi,
I'm working on writing a templated Binary Search Tree class in C++. In
regular C, I would have functions which traverse the tree take a pointer
to a user-defined function as an argument, which would then execute the
user-defined function for each node that is "visited". For example:
/* in the BST header file */
/* I actually don't remember if this is valid C or not */
typedef void (*fn)(void* tree_item);
void BST_inorder_traverse(const BST *tree, fn func);
/*...*/
void display_item(void* tree_item);
/*...*/
BST_inorder_traverse(tree, display); /* or something */
However, I'm not entierly certian how to do this in C++ if the BST is a
templated class. Is it possible to use typedef in conjunction with
templates? or is there some other 'correct' way of doing something like
this in C++?
Thanks,
Chris Schadl