#include <iostream>
#include <vector>
using namespace std;
class Figure {
public:
virtual void print() const = 0;
};
class Circle : public Figure {
public:
void print() const override {
cout << "Circle" << endl;
}
};
class Triangle : public Figure {
public:
void print() const override {
cout << "Triangle" << endl;
}
};
void log(const Figure &figure) {
figure.print();
}
int main() {
vector<Figure*> figures;
figures.push_back(new Circle());
figures.push_back(new Triangle());
for(auto &figure : figures) {
figure->print();
}
for(auto &figure : figures) {
delete figure;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgRmlndXJlIHsKCXB1YmxpYzoKCQl2aXJ0dWFsIHZvaWQgcHJpbnQoKSBjb25zdCA9IDA7Cn07CgpjbGFzcyBDaXJjbGUgOiBwdWJsaWMgRmlndXJlIHsKCXB1YmxpYzoKCQl2b2lkIHByaW50KCkgY29uc3Qgb3ZlcnJpZGUgewoJCQljb3V0IDw8ICJDaXJjbGUiIDw8IGVuZGw7CgkJfQp9OwoKY2xhc3MgVHJpYW5nbGUgOiBwdWJsaWMgRmlndXJlIHsKCXB1YmxpYzoKCQl2b2lkIHByaW50KCkgY29uc3Qgb3ZlcnJpZGUgewoJCQljb3V0IDw8ICJUcmlhbmdsZSIgPDwgZW5kbDsKCQl9Cn07Cgp2b2lkIGxvZyhjb25zdCBGaWd1cmUgJmZpZ3VyZSkgewoJZmlndXJlLnByaW50KCk7Cn0KCmludCBtYWluKCkgewoJdmVjdG9yPEZpZ3VyZSo+IGZpZ3VyZXM7CglmaWd1cmVzLnB1c2hfYmFjayhuZXcgQ2lyY2xlKCkpOwoJZmlndXJlcy5wdXNoX2JhY2sobmV3IFRyaWFuZ2xlKCkpOwoJCglmb3IoYXV0byAmZmlndXJlIDogZmlndXJlcykgewoJCWZpZ3VyZS0+cHJpbnQoKTsKCX0KCQoJZm9yKGF1dG8gJmZpZ3VyZSA6IGZpZ3VyZXMpIHsKCQlkZWxldGUgZmlndXJlOwoJfQoJCglyZXR1cm4gMDsKfQ==