Abstract class and operator!= in c++
<p>I have problem implementing the operator!= in a set class deriving from an abstact one. The code looks like this:</p>

<pre><code>class Abstract
{
  public:
     //to make the syntax easier let's use a raw pointer
     virtual bool operator!=(const Abstract* other) = 0;
};

class Implementation
{
    SomeObject impl_; //that already implement the operator!=
  public:
    bool operator!=(const Abstract* other)
    {
      return dynamic_cast&lt;Implementation*&gt;(other)-&gt;impl_ != this-&gt;impl_;
    }
};
</code></pre>

<p>This code works but it has the drawback to use dynamic_cast and I need to handle error in casting operation.</p>

<p>This is a generic problem that occur when a function of a concrete class it is trying to using some internal information (not available at the abstract class level) to perform a task.</p>

<p>Is there any better way to solve this kind of problem?</p>

<p>Cheers</p>
