add iterable
This commit is contained in:
+23
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user