c++ - Class member function address -


edit how in way related supposed post? both different errors, guys should stop trying farm rep

so i've been searching around google , stackoverflow couldn't find 1 solution case. have d3d9device pointer , want endscene address of device, how approach so?

dword aendscene = *(dword*)(&d3ddev->endscene); 

won't work following error

'&': illegal operation on bound member function expression 

i think that's wrong because i'm trying address of d3ddev class

member function pointers not per object, per type. in example, have multiple instances of idirect3ddevice9, of have same pointer value endscene member function (assuming aren't different concrete types - isn't likely).

the specific error getting because attempting address of pointer-to-member function object, isn't valid (eg. see '&' illegal operation on bound member function expression error).

it possible value of member function using type, instead of object pointer. however, it's extremely ugly:

// value stored in 'end_scene': hresult (idirect3ddevice9::* end_scene)() = &idirect3ddevice9::endscene; // call function, value of 'end_scene'. (*d3ddev.*(end_scene))(); // print address of pointer-to-member function: printf("%p\n", end_scene); 

i wouldn't suggest doing here, because functions in idirect3ddevice9 don't have same prototype. in fact, beginscene has same prototype endscene, , it's hard imagine situation in call 1 or other, since need called in specific order. make case using functions get/set vertex/pixel shader constants, have same prototypes, but, it's easy store other external state determine function call, , more straightforward.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -