Conversion C to C ++

0

Well, does anyone know what this code means in C ++?

#include <iostream>

#define MAX_C (10)
using namespace std;

int compar(const void *x, const void *y) {
    int a = *((int *) x);
    int b = *((int *) y);
    return a - b;
}
    
asked by anonymous 02.04.2016 / 23:58

1 answer

0

Good morning,

Looking at the code, the great difference is the use of the Library IOStream, which in this code, honestly, is not being valid. For at any moment it is called something from this library.

This #define is also not being used in this code. And if the goal is to have a constant, use const int = MAX_C 10;

As for the function, it returns the difference between two pointers. In which a cast is made for int.

It would be cool to use a Template, since we are talking about C ++.

Hugs

    
07.04.2016 / 15:07