/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/cpp/cpp-506-14-019/main.cpp
34 строки
749 B
Spirzen
OOP
09 июн 2026, 20:58
09 июн 2026, 20:58
1dca232
Код
Авторство
О чём код?
#include <iostream> #include <string> #include <algorithm> class Figure { public: std::string name; std::string color; Figure(const std::string& name, const std::string& color) : name(name), color(color) {} void describe() const { std::cout << "Фигура «" << name << "», цвет: " << color << std::endl; } }; class Circle : public Figure { public: explicit Circle(const std::string& color) : Figure("Круг", color) {} }; class Square : public Figure { public: explicit Square(const std::string& color) : Figure("Квадрат", color) {} }; int main() { Circle circle("красный"); Square square("синий"); circle.describe(); square.describe(); return 0; }