Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!iuvax!purdue!mentor.cc.purdue.edu!pur-ee!pur-phy!maxwell.physics.purdue.edu!sho From: sho@maxwell.physics.purdue.edu (Sho Kuwamoto) Newsgroups: comp.lang.c++ Subject: pointers to methods Message-ID: <3063@pur-phy> Date: 5 Feb 90 07:18:35 GMT Sender: news@pur-phy Reply-To: sho@maxwell.physics.purdue.edu.UUCP (Sho Kuwamoto) Organization: Purdue Univ. Physics Dept., W. Lafayette, IN Lines: 41 I'm not up on 2.0 (did Stroustrup come out with a book yet? I haven't been paying much attention to this group lately) but is there any standard way you can get a pointer to a member function? How does it work? I want something like this: funcPtr = className::func; instance->funcPtr(arg1, arg2); Not possible? Ach so. What about: funcPtr = instance->func; funcPtr(arg1, arg2); Although this version seems harder to implement and uglier to boot. Now for the big finale. I'd like something like this, but one which works for virtual functions. class old { | class new : public old { public: | public: virtual void fester(); | void fester(); }; | }; funcPtr = old::fester; oldThing->funcPtr(); newThing->funcPtr(); TaDaa! Another pipe dream. This would give me more faith that C++ was an object oriented programming language, with messages being passed around, so forth. As it is now, I can't shake the feeling that it's just a big program that mangles names for you. The only thing that differentiates C++ from such a mangler program (in my mind) is virutal functions. If something like the above is possible (which it might be), you'd also have containers to put messages in, which you could then send to different types of objects. -Sho -- sho@physics.purdue.edu <<-- now, all we need is a type variable. and standard support for generics (or maybe some other more elegant meta-class thing)