Advertisement

function pointers n classes

Started by May 16, 2001 08:54 AM
1 comment, last by EvilCrap 23 years, 8 months ago
hi im trying to write a sorta windows emulator, and i got a class, cWindow, and it has a member function pointer: void (*ProcName)() however, this function will obviously be unable to use private class members... wc.ProcName = blah the compiler wont allow access to members because the function pointed to isnt necessarily a member or freind of the class. how can i get around this?
well you need to get the index number of the function in the vtable
and i hope this function is a virtual one
otherwise derive the class and override that function

now click here!
and i hope it will help you
good luck!

Arkon
[QSoft Systems]
Advertisement
Borland added this feature to C++ Builder because it was sadly lacking in C++. They added the __closure directive so that you could declare function pointers that were actually methods of a class. A damned good idea that started in Delphi, was added to C++ Builder and will hopefully be added to the C++ standard in the near future. All other methods I have seen so far of calling methods from a function pointer are just clever hacks.

Steve ''Sly'' Williams  Code Monkey  Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

This topic is closed to new replies.

Advertisement