Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!metro!seagoon.newcastle.edu.au!jupiter.newcastle.edu.au!dgorton From: dgorton@jupiter.newcastle.edu.au (David Mark Gorton) Newsgroups: comp.lang.c++ Subject: pointers to member functions Message-ID: Date: 7 Jun 91 05:20:36 GMT Sender: news@neddy.newcastle.edu.au Distribution: comp Organization: Uni of Newcastle, Australia Lines: 72 In Stroustrups "The C++ Programming Language" pp 153-154 an example is given of how to "fake" the expression of the type of a pointer to a member function. Has this been standardised ? (I dont have access to a copy of the ARM at the moment, though I have one on order.) I am writing a class definition for TCP connections using the Transport Level Interface and have the following class definition class tcp { // TCP connection private : // Data members ... public : ... void ConnectionRelease(void); ... }; The sample program in the Sun Network Programming Guide has a C function connrelease() { ... } and in the server function run_server(...) { signal(SIGPOLL, connrelease); if (ioctl(conn_fd, I_SETSIG, S_INPUT) < 0) ... } I wish to do the equivalent in C++ using ConnectionRelease() from class tcp. The header file for on our SUN 3/80 has typedef void SIG_FUNC_TYP(int); typedef SIG_FUNC_TYP *SIG_TYP; extern "C" { SIG_TYP signal(int, SIG_TYP); ... }; The AT&T C++ Compiler accepts the following // // Fake type of pointer to member - See and "The C++ // Programming Language" - Bjarne Stroustrup, pp 153-154 for details // SIG_TYP pf = SIG_TYP(&tcp::ConnectionRelease); signal(SIGPOLL, pf); if (ioctl(fdConnection, (int) I_SETSIG, (caddr_t) S_INPUT) < 0) Is this correct (and the standard) ?? Thanks in advance, Dave --------------------------------------------------------------------------- Dave Gorton. Department of Computer Science, University of Newcastle, Newcastle, 2308, Australia. .-_|\ Telephone : (049) 216 034 / \ \.--._/ Internet : dgorton@cs.newcastle.edu.au v csdmg@cc.newcastle.edu.au ---------------------------------------------------------------------------