Is this safe casting??
I'm going off to re-check the blurb on
reinterpret_cast - but this doesn't look right to me.
I think it goes like this:
pointer to class member functions are not actually address, like normal pointers, they are actually
indexes.
So line 19 when you do this:
Main : EventManager() { setFunction(void (Dummy::*)()>(&Main::function)) }
you are getting the index of
Main::function which is a virtual function
This is passed to Line 11:
1 2 3 4
|
void setFunction(void (Dummy::*function)()) {
/.../
someFunc = reinterpret_cast<void (EventManager::*)(void)>(function);
}
|
But Event Manager has no virtual members - so the index into the virtual function table is invalid.
Well something like that anyway I think :-)