I get the error "Class 'Polygon' has virtual method 'area' but non-virtual destructor" in Eclipse CDT. Why? Code snippet:
Header files:
class Shape {
public:
virtual ~Shape();
protected:
virtual double area() const = 0;
}
class Polygon : public Shape {
public:
~Polygon();
protected:
double area() const;
private:
Vertex* vertices;
}
Implementation:
Polygon::~Polygon() {delete[] this->vertices;}
double Polygon::area() const {
...
return areaSum;
}
Sounds like a bug in eclipse, or maybe it's a 'style' warning about a minor issue. Polygon does have a virtual destructor automatically because it's base class destructor is virtual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With