Original Post
Alright, I'm working on a binary tree implementation. Since so far I have the sorting and add nodes done. I want to make a LNR function that allows pointers to functions for flexibility in manipulating the data inside. I've looked over the articles, but I didn't get it. Here's what I have so far:
//Declaration
void LNR(void(*FP)(Node*)); //In BTree class
//Definition
void BTree::LNR(void(*FP)(Node*))
{
BTree(Root->Left).LNR(FP);
FP(Root);
BTree(Root->Right).LNR(FP);
}
The above compiles, but when I try to call it via this:
int main()
{
BTree Tree;
for(int i = 0; i < 20; i++)
{
Tree.Add(rand()%100);
}
Tree.LNR(Tree.Display);
return 0;
}
It returns an error: error C2664: 'BTree::LNR' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(Node *)' Did I did the calling part wrong, or did I do the function wrong?