fork(3) download
  1. #include <iostream>
  2. #include <boost/ptr_container/ptr_vector.hpp>
  3. struct Base {
  4. virtual void f() { std::cout << "Base\n"; }
  5. virtual ~Base(){}
  6. };
  7. struct Derived : Base {
  8. void f() { std::cout << "Derived\n"; }
  9. };
  10. int main()
  11. {
  12. boost::ptr_vector<Base> v;
  13. v.push_back(new Derived);
  14. v[0].f();
  15. }
  16.  
Success #stdin #stdout 0s 2860KB
stdin
Standard input is empty
stdout
Derived