I'm trying to assign function pointer to a variable (the variable located in the base class) in derived class constructor.
My Code:
class A {
public:
virtual void print()=0;
protected:
unsigned long (*func)(unsigned char *,int)
}
unsigned long A::f1(unsigned char *c,int a){...}
unsigned long A::f2(unsigned char *c,int a){...}
class B: public class A {...}
B::B(int which){
switch (which){
case 1:
func=f1; //first error
break;
case 2:
func=f2; //second error
break;
}
Error:
error: cannot convert 'A::f1' from type 'long unsigned int (A::)(unsigned char ,int)' to type long unsigned int ()(unsigned char *,int)'
error: cannot convert 'A::f2' from type 'long unsigned int (A::)(unsigned char ,int)' to type long unsigned int ()(unsigned char *,int)'