>>626 class B { virtual void age() = 0; }; class B1 : public B { void age() { fusianasan(); } }; class B2 : public B { void age() { mokorimoko(); } }; class A { B* sage; void proc() { sage->age(); } }; class A1 : public A { A1() { sage = new B1; } }; class A2 : public A { A2() { sage = new B2; } };
g++のswitch `-fno-elide-constructors' The C++ standard allows an implementation to omit creating a temporary which is only used to initialize another object of the same type. Specifying this option disables that optimization, and forces g++ to call the copy constructor in all cases.