Files
cpp-course/modules/06_oop_basics/src/polymorphism.cpp
T

25 lines
562 B
C++
Raw Normal View History

2026-08-11 17:40:36 +03:00
#include "polymorphism.hpp"
namespace oop {
auto total_area(const std::vector<std::unique_ptr<Shape>>& shapes) -> double {
double total = 0.0;
for (const auto& shape : shapes) {
2026-08-15 21:00:19 +03:00
total += shape->area();
2026-08-11 17:40:36 +03:00
}
return total;
}
auto shape_names(const std::vector<std::unique_ptr<Shape>>& shapes)
-> std::vector<std::string> {
std::vector<std::string> names;
for (const auto& shape : shapes) {
2026-08-15 21:00:19 +03:00
names.push_back(shape->name());
2026-08-11 17:40:36 +03:00
}
return names;
}
auto Counter::copies() -> int { return copies_; }
} // namespace oop