Hello,
Using qsort in C we pass in a comparison function e.g.
int cmp(const void*, const void*);
the protoype of qsort expects a int (* )(const void* , const void*) so we call:
qsort(..., cmp);
but it is equally valid to call:
qsort(..., &cmp);
and this is what we would have to do if we passed in a static member-function in C++. Kernighan & Ritchie (2nd Edition, 5.11 "Pointers To Functions" p119) states that "since [cmp] is known to be a function, the & operator is not necessary, in the same way that it is not needed before an array name."
Does anyone else feel slightly uncomfortable with this (esp. regarding type-safety)?
Cheers, Chris