Comparing class objects using template max function
<p>I have written a template function like this:</p>

<pre><code>template &lt;class T&gt;
const T&amp; max1(const T&amp; x, const T&amp; y)
{
  if(y &lt; x)
    return x;
  return y;
}
</code></pre>

<p>Now, how can I use this function to compare two objects of class A where class A is like the following?</p>

<p><pre>
<code>
class A
{
public:
    A(int x){i=x;}</p>

<p>private:<br>
    friend bool operator&lt;(A const&amp; lhs, A const&amp; rhs) 
    {
        return lhs.i &lt; rhs.i;
    }</p>

<code>int i;
</code></pre>

<p>};
</code>
</p>

<p>I believe I have to overload &lt; operator but could not figure out how this whole process is working? Could you also provide a link to articles where I can read about this?</p>

<p>Thank you.</p>
