Question

I am trying to pass a function pointer to another function with an argument of type T.

Like so:

void preorder ( void ( *functptr ) (T&) ) // preorder traversal of tree
{
    preorder(root, functptr(T));

}

I understand that I need to pass an actual object to the function but this is being passed to another private function that actually knows what function it will be working with and I just need this public method to be a gateway between the two.

Was it helpful?

Solution

Try

template <typename T>
void preorder ( void ( *functptr ) (T&) )
{
    preorder(root, functptr);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top