shopiro@alice.UUCP (Jonathan Shopiro) (09/18/89)
In article <2560@pur-phy>, sho@maxwell.physics.purdue.edu (Sho Kuwamoto) writes: > So, what does (or should) it mean to take the address of a non static > member function? A member function is not like an ordinary function because it must be called in the context of an object of its class, e.g., struct Foo { // ``struct'' to make everything public void f(); }; Foo x; x.f(); // Foo::f() called as a member of x So, the address of a member function has to be different from the address of an ordinary function. Here, FOOMEM is the type of a member function. typedef void Foo::FOOMEM(); FOOMEM* fp = &Foo::f; // fp is a pointer to Foo::f() (x.*fp)(); // invoke the function pointed to by fp ... // ... as a mmember of x There is an analogous operator ->* In the case of virtual functions, the binding takes place at the time of call, not the time that the address is taken. -- Jonathan Shopiro AT&T Bell Laboratories, Warren, NJ 07060-0908 research!shopiro (201) 580-4229