#include #include #include using namespace std; struct A { public: virtual string s() { return "a"; } }; class B : public A { public: string s() { return "b"; } }; B make_b() { B b; return b; } A make_a() { return make_b(); } int main(void) { vector x; B b = make_b(); x.push_back(b); cout << x[0].s() << endl; B c; x.push_back(c); cout << x[1].s() << endl; return 0; }