[vtkusers] vtkInteractorStyle

Steffen Oeltze Steffen.Oeltze at Student.Uni-Magdeburg.DE
Sat Oct 5 05:46:13 EDT 2002

Alan McIntyre wrote:

> Steffen,
> As far as passing function pointers goes, there is a difference 
> between this:
>     obj->SetSomething(my_function());
> and this:
>     obj->SetSomething(&my_function); 

I receive an error during compiling saying that this is not a valid call 
for a member-function.


> The first one passes the result of a call to function() into the 
> SetSomething method, while the second one passes the address of the 
> 'my_function' function into the SetSomething method.  I think the '&' 
> in the second example isn't necessary in the eyes of some (most?) 
> compilers, but having it there doesn't do any harm as far as I know. 
> The second example is the one you want in your particular case.
> As for passing a C++ class method in as the parameter to 
> SetLeftButtonPressMethodArgDelete, I'm not exactly sure about the 
> 'proper' way to do that, since it appears to be expecting a plain C 
> function.  What kind of compiler error are you getting?
> I don't have the VTK source on my machine here at home right now, so 
> I'm kind of in the dark as to the usage/behavior of 
> SetLeftButtonPressMethodArgDelete, but I'm wondering if the reason the 
> it expects a pointer to a function with a void* parameter is so that 
> class methods can be given to it.  If I recall correctly, isn't the 
> pointer to the object pushed onto the stack (kind of like an invisible 
> first parameter) when calling class methods?   If that's the case, 
> perhaps the get_mousePos(void*) method in Steffen's example could be 
> passed if it was declared like this:
>     void get_MousePos();
> Somebody please let me know if I'm totally clueless here; I don't want 
> to give Steffen any bad info.
> Thanks,
> Alan 

Thank you very much,


More information about the vtkusers mailing list