home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!ames!decwrl!csus.edu!netcom.com!dx
- From: dx@netcom.com (dx)
- Subject: Invoking functions passed as parameters
- Message-ID: <1992Nov10.192709.682@netcom.com>
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- Date: Tue, 10 Nov 1992 19:27:09 GMT
- Lines: 24
-
- In standard C, function pointers passed as paramters are invoked with
- the standard C syntax, e.g.,
-
- foo(void (*pf)(parmeters))
- {
- pf(paremeters)
- }
-
- Now suppose I have a class PFCLASS, and pf points to a member function of
- this class, and within foo I want to apply the method pointed to by pf to
- an instance of PFCLASS, pointed to by pInstance.
-
- In standard C syntax, I would make the member function take the pointer to
- the instance as a parameter, and use the standard way to call the function:
-
- pf(pInstance);
-
- But I wonder if there is some way to invoke the method pointed to by pf
- in a more C++ like way, such that pInstance turns up as the 'this' pointer
- in the method, rather than having to pass it as a parameter.
-
- Any ideas?
-
- -dx
-