What I want to do is pass a function to a function. The function that is to receive a function is a recursive function. It is to call the passed function. I have a short (one page) example of this in my book but that is it and I can't get the compiler to accept the code.
The error is stating of a mismatch between the formal and actual parameters, error converting from " void (Node &) to Vode (_cdecl *)(Node *) " The prototypes are void PrintNodeData(Node *sentNode); and int RecursiveDataPrint(Node* sentPtr,void(*sent)(Node *));. I then call with this line RecursiveDataPrint(Root,PrintNodeData); The error is with parameter 2. I don't know what the compiler is saying when it has "(_cdecl *)".
Any ideas?
Randy
shortLived
1
Newbie Poster
Recommended Answers
Jump to Post>I can't get the compiler to accept the code
So post the code. It's easier to figure out your problem when you give us more than just the bits and pieces that you think are causing the problem.
Jump to PostPrintNodeData is a member function, and you treat pointers to member functions differently than pointers to functions.
All 6 Replies
Narue
5,707
Bad Cop
Team Colleague
shortLived
1
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
shortLived
1
Newbie Poster
shortLived
1
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.