I have a class in which i want to have a member variable for a method:
template<typename T>
class ParamTest : public Action<T> {
public:
typedef void (*mixfunctype)(const T &t1, const T &t2, T &t3, double dParam);
mixfunctype curFunc;
void setMode(int iMode);
...
protected:
void test1(const T &t1, const T &t2, T &t3, double dParam);
void test2(const T &t1, const T &t2, T &t3, double dParam);
...
}
and in the code
template<typename T>
void ParamTest<T>::setMode(int iMode) {
if (iMode == 0) {
curFunc = &test1;
} else {
curFunc = &test2;
}
}
But the compiler doesn't like this
error: cannot convert ‘void (ParamTest<int>::*)(const int&, const int&, int&, double)’ to ‘ParamTest<int>::mixfunctype’ {aka ‘void (*)(const int&, const int&, int&, double)’} in assignment
curFunc = &test1;
How should i declare the variable curFunc
, and how should i assign a function to it, to have compilable code?