I had built a set of linked-list functions and decided to put them 
into a class. I am having some difficulty with using function 
pointers -- specifically doing a sort.

Prior to moving to the class structure, I had:

// Calling procedure
byPath = (struct ENTRY *)listsort(origList, compare_Path);

// listsort
ENTRY *listsort(ENTRY *list, int(*compare)(void *, void *))
{
...
result = (*compare)(p,q));
...
}

// compare_Path
int compare_Path(void *p, void *q){}

THIS ALL WORKS CORRECTLY
---------------------------------
Now that I've moved the functions into a class, I can't get the sort 
to work. I call it like this:
// Calling procedure
obj.sort(compare_Paths);

// listsort
void Entry::sort(int(*compare)(void *, void *)){}

// compare_Paths
int Entry::compare_Paths(void *p, void *q){}

I get an error at the calling procedure line: 'compare_Paths' was not 
declared in this scope. I have included the Entry.h file and have the 
declaration for compare_Paths in the Public: part of my class.

If I call it with
obj.sort(Entry::compare_Paths);

I get 2 errors:
No matching function for call to 'Entry::sort(<unknown type>)'
Candidates are void Entry::sort(int(*)(void*, void*))


I have also tried creating a sortPaths() function.

// Calling procedure
obj.sortPaths();

// sortPaths
void Entry::sortPaths()
{
     sort(Entry::compare_Paths);
}

I get 2 errors:
No matching function for call to 'Entry::sort(<unknown type>)'
Candidates are void Entry::sort(int(*)(void*, void*))

Any assistance in getting this to work will be appreciated.

~Rick

Reply via email to