how does a function "const void *foo( param, param) work"?

Asked

Viewed 99 times

1

bool cmp(const void * a, const void * b) {
  return static_cast < /*type?*/ * > a < static_cast < /*type?*/ * > b;
}

const void * min(const void * first, const void * last, size_t size, compare cmp) {
  void * minor = * first;
  while (first != last) {
    if (cmp(first, first++)) {
      * minor = * first;
    }

    * first++;
  }
}

I’m trying to do a function that the output is the first occurrence of the smallest element, and the prototype of the function is

const void * min(const void * first, const void * last, size_t size, Compare cmp);

and need to program the Cmp function that returns true if a < b and the prototype has to be

bool cml ( const void * a, const void * b);

Obs: the code has to be done in c++

  • 1

    I’m not sure what you’re asking. want to know what the function that is passed as parameter is like?

  • also not understood very well, you want to understand why the type of return is const void ? Take a look here

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.