Topic: How to pass a member function as a reg func ptr?
Author: jlieb@is.morgan.com (Jerry Liebelson)
Date: Thu, 3 Jun 1993 14:08:47 GMT Raw View
Hi,
I have a SortedTable class that is a container class of Record
objects sorted by a particular sequence and direction (ascending or
descending) of the individual Fields in each Record. This particular
sorting sequence and direction is specific to each instance of the SortedTable
and so the compare() routine (which compares 2 Records) has to be a
member function of SortedTable.
class SortedTable
{
//...
private:
ThirdParty_SortedVector records;
int compare(const void*, const void*);
// other members for specifying sorting sequence
}
I want to pass this compare() routine to a third-party function that
does the binary search on the collection of Records. But this routine
wants an argument of type
int (*compareFun)(const void*, const void*)
and not, of course,
int (FxSortedTable::*)(const void*, const void*)
And this difference, apparently cannot be casted away.
So, THE QUESTION IS,
Is there any way I can pass a member function to a routine that wants
a non-member function ptr? Or, is there another way to do this that
somebody can suggest?
Thanks
Jerry Liebelson
jlieb@is.morgan.com
73477.2740@compuserve.com