From: Paul Harness Subject: Re: Internal function pointers To: wrh AT placer1 DOT wimsey DOT com Date: Fri, 12 Aug 1994 10:30:03 +0100 (BST) Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (djgpp) > class x > { > protected: > void (*paction)(void *p); > ... > public: > void setaction(void (*)(void *)); // stores to paction > ... > } > > class y:x > {...} > > class z:x > { > protected: > class y one,two,three; > ... > void myfunc(void *); > void myotherfunc(void); > ... > public: > ... > } > > void z::myotherfunc(void) > { > one.setaction(myfunc); > } > > Now, djgpp doesn't compile this, it complains about my prototyping. > What gives? > The problem is the difference between a `pointer-to-a-function' and a `pointer-to-a-member-function'. A pointer to member function also contains information about the class of which it is a member. i.e., returntype (x::*)(args) ptr-member-fn returntype (*)(args) ptr-fn If you really need pointer to function syntax, the only way around this is to either (a) use static member fns or (b) call the member fn via a ordinary `wrapper fn' that accesses the object via, for example, a global. Paul -- Paul Harness, | Internet: gapa83 AT udcf DOT gla DOT ac DOT uk Department of Physics and Astronomy, | University of Glasgow, | Tel +44-41-339-8855 ext 8359 Glasgow, G12 8QQ, SCOTLAND. | Fax +44-41-334-9029