Skip to main content
edited body
Source Link
Eitan T
  • 33k
  • 14
  • 77
  • 111

I have the following code:

#include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc mr; HandlerFunc mm() {   return mr;   } void sample(int a, int b, HandlerFunc func) {   }   void main() {   sample(1, 2, mm); } 

Here i amI'm trying to passingpass a function of type HandlerFunc as parameterHandlerFunc to another function. I, but I am getting an error.:

Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)''void (__cdecl *(void))(int,int)' to 'void (__cdecl )(int,int)''void (__cdecl *)(int,int)'

If iI type cast as sample(1,2,(HandlerFunc)mm);sample(1, 2, (HandlerFunc)mm); everything works fine. 
Can anyone tell what is the way to solve the error issue.?

I have following code

#include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc mr; HandlerFunc mm() { return mr;   } void sample(int a,int b,HandlerFunc func) {   } void main() {   sample(1,2,mm); } 

Here i am trying to passing function of type HandlerFunc as parameter to another function. I am getting an error.

Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)' to 'void (__cdecl )(int,int)'

If i type cast as sample(1,2,(HandlerFunc)mm); everything works fine. Can anyone tell what is the way to solve the error issue.

I have the following code:

#include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc mr; HandlerFunc mm() {   return mr; } void sample(int a, int b, HandlerFunc func) { }   void main() { sample(1, 2, mm); } 

Here I'm trying to pass a function of type HandlerFunc to another function, but I am getting an error:

Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)' to 'void (__cdecl *)(int,int)'

If I type cast as sample(1, 2, (HandlerFunc)mm); everything works fine. 
Can anyone tell what is the way to solve the error issue?

added 3 characters in body
Source Link
hmjd
  • 122.4k
  • 21
  • 216
  • 259

I have following code

#include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc mr; HandlerFunc mm() { return mr; } void sample(int a,int b,HandlerFunc func) { } void main() { sample(1,2,mm); } 

Here i am trying to passing function of type HandlerFunc as parameter to another function. I am getting an error. Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)' to 'void (__cdecl )(int,int)' If

Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)' to 'void (__cdecl )(int,int)'

If i type cast as sample(1,2,(HandlerFunc)mm); everything works fine. Can anyone tell what is the way to solve the error issue.

I have following code

#include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc mr; HandlerFunc mm() { return mr; } void sample(int a,int b,HandlerFunc func) { } void main() { sample(1,2,mm); } 

Here i am trying to passing function of type HandlerFunc as parameter to another function. I am getting an error. Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)' to 'void (__cdecl )(int,int)' If i type cast as sample(1,2,(HandlerFunc)mm); everything works fine. Can anyone tell what is the way to solve the error issue.

I have following code

#include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc mr; HandlerFunc mm() { return mr; } void sample(int a,int b,HandlerFunc func) { } void main() { sample(1,2,mm); } 

Here i am trying to passing function of type HandlerFunc as parameter to another function. I am getting an error.

Error :*: cannot convert parameter 3 from 'void (__cdecl *(void))(int,int)' to 'void (__cdecl )(int,int)'

If i type cast as sample(1,2,(HandlerFunc)mm); everything works fine. Can anyone tell what is the way to solve the error issue.

Source Link
Loading