I have this setup:
I have a class, and one of the members is a function pointer. I want to be able to implement various possible versions of the function it points to in the same class the function pointer resides in. However, I get various errors when I try to initialize the function pointer to a function that also is a member of the same class.
I've shown the first part, then the error it generates, then in the second part I try to remedy it by declaring the function pointer to be a member of the Vec class, but it still doesn't work (I show the error codes of visual C++ 6). Of course, I couldn't then put this same function pointer in the baseclass, but it could at least point to a member function (sadly I can't even get this much to work properly).
using namespace std;
//pFunc is of data type function pointer which returns void, accepts void as formal parameter
cout << "This is just some func" << endl;
x = y = z = w = 0;
funcPtr = 0;
cout << "This is the vector func" << endl;
float w; //complex plane
a.funcPtr = SomeFunc; //works
a.funcPtr = Vec::VectorFunc; //error:
error C2440: '=' : cannot convert from 'void (__thiscall Vec::*)(void)' to 'void (__cdecl *)(void)'
b = Vec::VectorFunc;
error C2064: term does not evaluate to a function