25 lines
562 B
C++
25 lines
562 B
C++
#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) {
|
|
total += shape->area();
|
|
}
|
|
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) {
|
|
names.push_back(shape->name());
|
|
}
|
|
return names;
|
|
}
|
|
|
|
auto Counter::copies() -> int { return copies_; }
|
|
|
|
} // namespace oop
|