fork download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. struct Base{
  5. virtual std::unique_ptr<Base> clone() const = 0;
  6. };
  7.  
  8. struct Derived : Base{
  9. std::unique_ptr<Base> clone() const{
  10. return std::make_unique<Derived>();
  11. }
  12. };
  13.  
  14. int main() {
  15. Derived d;
  16. auto upd = d.clone();
  17. }
Success #stdin #stdout 0s 3452KB
stdin
Standard input is empty
stdout
Standard output is empty