Point to a function, that is.
I have a class called viewPort, which is a simple 2D raster graphics class. I want there to be several plotting functions (such as overlay, XOR, blend, etc) so I thought I'd use a function pointer.
Here is an abridged code portion
The line in bold generates a compile-time error: cannot convert from (__thiscall viewPort::*) (int, int, int) to (__cdecl *) (int, int, int).Code:class viewPort { . . . public: void plot (int x, int y, int col); void (*plotH) (int x, int y, int col); }; . . . viewPort::viewPort (int width, int height, HWND hwnd) { . . . plotH = plot; . . . }
I really don't know what's wrong. I've used function pointers before with no problems - but not with class member functions. I looked function pointers up in C++ Primer and it makes no mention of any exceptions when pointing to member functions.
As far as I can see, this is a non-error. It's a pointer in viewPort to a void (int, int, int) and I'm trying to point it to a void (int, int, int) which is also in the viewPort class.
And to add insult to injury, when I try to do what it wants and typecast to (__cdecl *) it says it doesn't recognise __cdecl DESPITE it changing colour when I type it.
I'm totally stuck.