Ошибка в функции класса

Рейтинг: 0Ответов: 0Опубликовано: 28.04.2023

Rectangle::operator-: Возвращаемый тип перегруженной виртуальной функции отличается от "Length::operator-" и не является ковариантным. Что делать?

class Length {
protected:
    double length;

public:
    Length() : length(0) {}

    Length(const double l) : length(l) {}

    virtual ~Length() {}

    void SetLength(const double l);

    double GetLength() const;

    virtual double Area() const;

    Length& operator=(const Length& l2);

    virtual void Print() const;

    virtual bool operator==(const Length& l2) const;

    virtual bool operator!=(const Length& l2) const;

    virtual Length operator-(const double x) const;
};

class Rectangle : public Length {
protected:
    double width;

public:
    Rectangle() : Length(), width(0) {}

    Rectangle(const double l, const double w) : Length(l), width(w) {}

    ~Rectangle() {}

    void SetWidth(const double w);

    double GetWidth() const;

    double Area() const;

    Rectangle& operator=(const Rectangle& r2);

    void Print() const;

    bool operator==(const Rectangle& r2) const;

    bool operator!=(const Rectangle& r2) const;

    Rectangle operator-(const double x) const;
};

Ответы

Ответов пока нет.