title: How to make Comparable Class in C++
body: <p>I want to make an interface in C++.
  How can I get op2.radius value in operator overloading statement?
  I'd like that Comparable Class can be used for others such as Rectangle, Line etc.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Comparable {
        public:
               virtual bool operator &gt; (Comparable&amp; op2)=0;
               //virtual bool operator &lt; (Comparable&amp; op2)=0;
               //virtual bool operator == (Comparable&amp; op2)=0;
  };
  
  class Circle : public Comparable {
        int radius;
        public:
               Circle(int radius=1) { this-&gt;radius = radius; }
               int getRadius() { return radius; }
               bool operator &gt; (Comparable&amp; op2)
               {
                    if (radius &gt; op2.radius) // &lt;-- here!
                    return true;
                    else
                    return false;
               }
  
  };
  
  template &lt;class T&gt;
  T bigger(T a, T b){
             if (a &gt; b) return a;
             else
             return b;
  }
  
  void main()
  {
      Circle waffle(10), pizza(20), y;
      y = bigger(waffle, pizza);
      cout &lt;&lt; "the bigger one is " &lt;&lt; y.getRadius() &lt;&lt; endl;
  }
  </code></pre>