title: C++ : Polymorphism and operator overloading
body: <p>i am having troubles figuring out how overload comparison operators have to be done when i am using an abstract base class. The main problem is to achieve polymorphism using that base class, since it's abstract it can't be instantiated so i am forced to use a pointer to that base class in order to access the derived class methods. 
  I'll put some code in order to describe the situation better : </p>
  
  <pre><code>template &lt;typename _Tp&gt;
  class Base 
  {
      private: 
         _Tp attr ; 
      public: 
         foo() = 0 ; 
         friend bool operator == ( Base* b1, Base* b2)  
         {
             return ( b1.attr == b2.attr ) ;
         }
  }; 
  
  template &lt;typename _Tp&gt; class Derived_1 : public Base&lt;_Tp&gt; { /.../ } ;
  template &lt;typename _Tp&gt; class Derived_2 : public Base&lt;_Tp&gt; { /.../ } ; 
  
  int main (void)
  {
      vector&lt;Base*&lt;int&gt; &gt; * v = new vector&lt;Base*&lt;int&gt; &gt; (2,0) ; 
      v[0] = new Derived_1 () ; 
      v[1] = new Derived_2 () ; 
      if ( (*v)[0] == (*v)[1] ) { /.../ }
      return 0 ;
  }
  </code></pre>
  
  <p>So, at this point you will notice that <code>(*v)[0] == (*v)[1]</code> its a pointer comparison of <code>Base*</code>. I want to know if there is a way to overload the comparison operator between these two pointers, since the overloaded operator that is defined in the base class is never used.</p>
  
  <p><strong>Edit after responses:</strong> </p>
  
  <p>Since in my real code, the comparison must be <code>(*v)[0] == (*v)[1]</code> i can not compare the objects because my data structure would lose generality. Thus, what i am trying to ask you is this: </p>
  
  <p>Can the comparison of <code>Base</code> pointers be done? How? </p>
  
  <p>I'm getting errors from the compiler telling me : </p>
  
  <blockquote>
    <p>bool operator == (Base*,Base*) must have an argument of class or enumerated type.</p>
  </blockquote>