not sure what this syntax means

I've never seen a function declared like this, specifically the (*visit)(int&)

 
void inorder(void (*visit)(int &));


what is this called? how does it work?

The way I am looking at it I see: dereference visit, multiply it by an int.... but it makes no sense to me in the context it's used.

Last edited on
'visit' is a pointer to a function that returns nothing and takes a reference to an int.
It can be rewritten like this:
1
2
3
typedef void (*fp)(int &);

void inorder(fp visit);
void (*visit)(int &) looks like a function pointer to me. One of the obscure abilities of C/C++.

Could you post the function? You only have the prototype there.

ah ok. thanks guys. I've never used a function pointer before. Now I know what it is :)
Topic archived. No new replies allowed.