#include <iostream>
#include <vector>
#include <memory>

struct foo {
	virtual void print() =0;
};

struct goo : public foo {
	int a;
	void print() { std::cout << "goo"; }
};

struct moo : public foo {
	int a,b;
	void print() { std::cout << "moo"; }
};
typedef std::unique_ptr<foo> foo_ptr;
int main() {
	std::vector<std::unique_ptr<foo> > foos;
	foos.push_back(foo_ptr(new moo));
	foos.push_back(foo_ptr(new goo));
	foos.push_back(foo_ptr(new goo));
	foos.push_back(foo_ptr(new moo));
	
	for(auto it = foos.begin(); it!=foos.end(); ++it) {
		it->get()->print();
	}
	return 0;
}