On Sat, 4 Oct 2003 21:18:41 +0200 "Laurent Houdusse" <l houdusse free fr> wrote:
I have created a new class dw3D where RenderFrame is a method (int dw3D::RenderFrame();) so the previous code become: dw3D oDw3D; oDw3D.Init(oWindow->window); gtk_idle_add((GtkFunction)oDw3D.RenderFrame, NULL); gtk_main (); but when i compile, i have an error: 'type cast' : cannot convert from '' to 'int (__cdecl *)(void *)' why?? what is the problem?
You cannot use a regular C++ member function. Remember that a function pointer (like GtkFunction) is just an address of a piece of code. To call a C++ member function, the address of the code is not enough (unless it is a static member function). You also need the address of the object instance that invokes the method. This is called the "this" or "self" pointer in OO speak. Since GtkFunction doesn't have room for that, it won't work. The obvious solution is to write a wrapper function in C that - creates your dw3D object (if necessary) - calls oDw3D.RenderFrame Roland -- R.F. Smith /"\ ASCII Ribbon Campaign r s m i t h @ x s 4 a l l . n l \ / No HTML/RTF in email http://www.xs4all.nl/~rsmith/ X No Word docs in email / \ Respect for open standards
Attachment:
pgpe_pw1a8hsa.pgp
Description: PGP signature