Utilisation de l’algorithme ‘max()’ avec une fonction de comparaison

Author:


Download

#include 
#include 

using namespace std;

bool int_ptr_less (int* a, int* b)
{
    return *a < *b;
}

int main()
{
    int x = 17;
    int y = 42;
    int* px = &x;
    int* py = &y;
    int* pmax;

    // call max() with special comparison function
    pmax = max_element (px, py, int_ptr_less);
    cout << *pmax;
    //...
}

Leave a Reply

Your email address will not be published. Required fields are marked *