fork(1) download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. class Base {
  6. protected:
  7. ~Base() {
  8. cout << "B\n";
  9. }
  10. };
  11.  
  12. class Derived : public Base {
  13. public:
  14. virtual ~Derived(){
  15. cout << "D\n";
  16. }
  17. };
  18.  
  19.  
  20. int main() {
  21.  
  22. std::shared_ptr<Base> myBaseS(new Derived());
  23. //std::unique_ptr<Base> myBaseU(new Derived());
  24.  
  25. // Base *myBase_raw = new Derived();
  26. // delete myBase_raw;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 4364KB
stdin
Standard input is empty
stdout
D
B