Re: [Dev-C++] Static members for callbacks
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Abhijit S. <mu...@gm...> - 2002-07-27 09:02:07
|
> You can have a function pointer to point to some member functions. But a
> non-static member function is not a regular function, that's why we use
> special-kind of pointers (a static function on the other hand is a
> regular function).
>
> #include <iostream>
>
>
> int main()
> {
> class A
> {
> public:
> void something() { std::cout<<"Hello, new world!\n"; }
> }a;
>
> void (A::*pf)()=&A::something;
Okay, so this is how it's done... thanks. But this means that you can't use
non-static methods for external callbacks (like Windows') directly.
Waitaminit... in what you've done above, aren't all objects' 'pf's set to
A::something? What if I want one object's pf pointing to something, and
another object's pf poiting to something_else?
|