add iterable

This commit is contained in:
2025-07-28 17:03:05 +07:00
parent 765bfc3502
commit b20b5dec53
9 changed files with 217 additions and 23 deletions
+23
View File
@@ -0,0 +1,23 @@
#include <iostream>
#include <memory>
#include "main.h"
int main() {
auto c1 = std::make_shared<Circle>(3.0);
auto c2 = std::make_shared<Circle>(5.0);
auto c3 = std::make_shared<Circle>(7.0);
c1->set_next(c2.get());
c2->set_next(c3.get());
std::cout << "Forward:\n";
for (auto& shape : c1->traverse<IShape::forward>()) {
shape.draw();
}
std::cout << "\nBackward:\n";
for (auto& shape : c1->traverse<IShape::backward>()) {
shape.draw();
}
}