Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!cuae2!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsb!kenny From: kenny@uiucdcsb.cs.uiuc.edu Newsgroups: comp.lang.c++ Subject: Address of overloaded member fn.? Message-ID: <165700001@uiucdcsb> Date: Fri, 5-Dec-86 01:20:00 EST Article-I.D.: uiucdcsb.165700001 Posted: Fri Dec 5 01:20:00 1986 Date-Received: Sun, 7-Dec-86 20:49:20 EST Lines: 42 Nf-ID: #N:uiucdcsb:165700001:000:1742 Nf-From: uiucdcsb.cs.uiuc.edu!kenny Dec 5 00:20:00 1986 Is there any way, in current C++, to take the address of an overloaded member function. I understand that the compiler will be able to determine the type of (&cl::entrypoint) by the type of the receiving pointer in an assignment statement, but there doesn't seem to be any way to do it at present. The closest I came was: ------------------------------------------------------------------------ class testclass { public: testclass& operator- (); testclass& operator- (testclass); testclass (); }; typedef testclass& (*NILADIC) (void*); typedef testclass& (*MONADIC) (void*, testclass); typedef testclass& (*CONSTRUCTOR) (); main () { NILADIC niladic = &testclass :: operator-; MONADIC monadic = &testclass :: operator-; CONSTRUCTOR constructor = &testclass :: testclass; } ------------------------------------------------------------------------ which gives the following: ------------------------------------------------------------------------ "memptrtest.c", line 16: error: cannot deduce type for &overloaded _minus() "memptrtest.c", line 16: sorry, <> cannot recover from earlier errors ------------------------------------------------------------------------ and I don't see any obvious way to disambiguate the overloaded operator. Any ideas? I could kludge around it by making a named function that in turn calls the operator, but that's even uglier than the usual pointer-to-entry-function kludge (plus, it hasn't been blessed by Mr Stroustrup). Kevin Kenny UUCP: {ihnp4,pur-ee,convex}!uiucdcs!kenny Department of Computer Science ARPA: kenny@B.CS.UIUC.EDU (kenny@UIUC.ARPA) University of Illinois CSNET: kenny@UIUC.CSNET 1304 W. Springfield Ave. Urbana, Illinois, 61801 Voice: (217) 333-8740