For comparison, an algorithm relies on the fundamental == and < operators, as in the case of an integer. To be able to use your own classes with algorithms, operator== and operator< must either be provided by the class or as an argument to the algorithm.
The following example shows these operators implemented in a simple Flower class, where operator== is utilized by std::find, and operator< is utilized by std::max_element.
struct Flower { // Is equal operation, used when finding auto operator==(const Flower& f) const { return height_ == f.height_; } // Is less than operation, used when sorting auto operator<(const Flower& f) const { return height_ < f.height_; } int height_{};};auto garden ...