Why doesn't a const method override a non-const method in C++?
<p>Consider this simple program</p>

<pre><code>class Shape
{
public:
    virtual double getArea() = 0;

};

class Rectangle : public Shape
{
    int width;
    int height;

public:
    Rectangle( int w , int h ) :width(w) , height(h) {}

    double getArea() const
    {
        return width * height;
    }
};


int main() {

    Rectangle* r = new Rectangle(4,2);
}
</code></pre>

<p>Trying to compile this problem gives me </p>

<pre><code> 'Rectangle' : cannot instantiate abstract class
</code></pre>

<p>Why is this not allowed in C++ when covariant return types are ? <strong>Of course I can fix the program by making <code>Rectangle::getArea</code> to be a non-const function</strong> but I am curious as to why the language designers decided otherwise.</p>

<p><strong>EDIT</strong></p>

<p>Lot of people have mentioned in their answers how the signature is different. But so is</p>

<pre><code>class Shape
{
public:
    virtual BaseArea* getArea() = 0;

};

class Rectangle : public Shape
{
public:
    virtual RectangleArea* getArea();
};
</code></pre>

<p>but C++ went out of their to allow it when C# doesn't.</p>

<p>C++ supports covariant return types because if i expect an interface to return an BaseArea* and an implemenation that returns as RectangleArea* it is ok if RectangleArea derives from BaseArea because my contract is met.</p>

<p>In the same lines isn't an implementation that provides an non-mutating function satisfying an interface that only asks for a mutating function.</p>
