I have an assignment where the teacher gave us the template class definition and we have to write the function implementation. However, I'm confused about something he put in the class definition:
void inorder (void (*) (T&);
I've never seen void (*) as a parameter passed to a function. I've tried searching on GOOGLE but I can't seem to find anything,-- maybe because I don't know what this is called so I'm not searching correctly. Could someone please explain what this code is doing? Let me know if I need to add more information to make my question clear.
void (*) is a function pointer. If you have pointer to int, pointer to float, ... you also have pointer to function.
A function's type is identified by its return type and its parameters.
Ex: int sum(int a, int b);
and int difference(int a, int b);
and double division(int a, int b);
sum and difference are similar: they both return int and take parameters (int,int). division is not, because it returns double, despite of having the same parameters (int,int)
So if int * is a pointer to int, then: int (*) (int, int) is a pointer to function returning an int and taking 2 ints. double (*) (int, int) is a pointer to function returning a double and taking 2 ints. int (*) (double, int) is a pointer to function returning an int and taking 1 double, 1 int.
void (*) (T&) is a pointer to function returning nothing and taking a reference to T.
Any function that returns nothing and takes a reference to T can be passed to inorder