Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!unido!zgdvda!viktoria.grz!dingelde From: dingelde@viktoria.grz (Dennis Dingeldein) Newsgroups: comp.lang.c++ Subject: Again: Pointer to methods ? Keywords: Pointers to methods Message-ID: <2292@zgdvda.zgdvda.uucp> Date: 10 Aug 90 08:48:33 GMT Sender: news@zgdvda.zgdvda.uucp Organization: ZGDV Darmstadt, FRG Lines: 60 Hello! I scanned our old articles of "comp.lang.c++" but couldn`t find a *real* solution to the following problem. I`m sorry if that problem was already solved last year :-) Problem: 1. The method of my class needs to accept a pointer to a method of another class. MyClass::SetPointer( ) 2. At compile time of my class I don`t know anything about the other class. 3. SetPointer must be a *method* (of my class), no C function. 4. A solution like "Use a third class with virtual method "SetPointer" and derive from that class "SetPointer" methods with the appreciated parameters" is not the one I like to use. This seems to me like "programming around the problem because I couldn`t solve it". I`ll give a simple example, what I wan`t to do with that method // ----- start of example // class Menu provides a pulldown functionality class Menu { public: SetPointer( ???? ); // the method ???? will be called if any // Menu Entry is selected (not senseful, I know) Start(); // display and start the interaction with the menu ... }; // class Circle is unknown class, here only for the example visible // it provides the output behaviour of a circle. class Circle { public: Draw(); // displays the circle }; // main shows a menu and draws the circle on selection main() { Menu MyMenu( "Draw Circle" ); Circle MyCircle( ... ); MyMenu.SetPointer( MyCircle::Draw( ... ) ); // If the User selects an entry , the circle is drawn! Menu.Start(); } Who know's what to do ? What`s the prototype of Method "SetPointer" ? Dennis Dingeldein ZGDV Zentrum fuer Graphische Datenverarbeitung (dingelde@zgdvda.uucp) Wilhelminenstr. 7 D-6100 Darmstadt, West Germany Phone: +49/6151/155-121