Untitled
unknown
c_cpp
3 years ago
1.0 kB
6
Indexable
#ifndef INC_5_CIRCLE_H
#define INC_5_CIRCLE_H
#include <iostream>
#include "Ellipse.h"
class Circle : private Ellipse { // наслідування від класу Ellipse
public:
Circle() : Ellipse() {}; //Конструктор за замовчуванням
Circle(double x, double y) : Ellipse(x, y) {} //Конструктори ініціалізації
Circle(double x, double y, double rad) : Ellipse(x, y, rad, rad) {}
~Circle() = default; //Деструктор
// Обчислення площі. Перевизначаємо virtual метод area(), тут пояснення таке ж, як і в класі Circle =)
double area() override {
auto &ellipse = static_cast<Ellipse &>(*this);
return ellipse.area();
}
// перевантаження методу виведення (<<)
friend std::ostream& operator<<(std::ostream &os, const Circle &circle) {
os << static_cast<const Ellipse&>(circle);
return os;
}
};Editor is loading...