Re: general func. ptr.

New Message Reply Date view Thread view Subject view Author view

Swaminathan N. (swami++at++evl.uic.edu)
Fri, 4 Jul 1997 00:13:29 -0500 (CDT)


On Thu, 3 Jul 1997, Marcus Barnes wrote:

> On Jul 2, 10:16am, Nicolas Gauvin wrote:
> > On Jun 29, 3:00pm, Swapnil Shah wrote:
> > > I know that pointer to function and pointer to method in class is
> > > different. Now can someone tell me how do i have some general pointer,
> > > which can point to different methods of different objectes/classes ???
> >
> > My understanding is that it is not possible to save a pointer to a true
> > member function partly because of the implicit 'this' parameter.
>
> It is possible to declare a pointer to a class member. The syntax is described
> in "The C++ Programming Language, 2nd Edition", chapter 5.4.5. I don't recall
> if any of SGI's C++ compilers support this language feature yet.

Pointers to data members and member functions are currently supported. The
question is whether pointers to member functions and pointers to static or
plain ol' functions are interchangeable, which of course, they are not.
However, pointers to member functions in C++ support the virtual function
mechanism, meaning that a call through a base class PMF might actually call a
derived class virtual function. This is one way of having a generic PMF which
can also be used to point to the derived class member functions (with the same
signature). This is not very interesting or flexible.
Options include the generic callback library implemented by Rich Hickey,
function objects (or functors), or just a better design :-)

bye
Swami

 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
v Swaminathan Narayanan ^
v swami++at++evl.uic.edu ^
v Office: 996-3002 ^
v Home: 850-2726 ^
v http://www.evl.uic.edu/swami ^
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:34 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.