fork download
  1. #include <memory>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. struct Test{
  6.  
  7. shared_ptr< Test > ptr;
  8.  
  9. Test(){ cout<<"Test c-tor"<<endl; }
  10.  
  11. ~Test(){ cout<<"Test d-tor"<<endl; }
  12.  
  13. };
  14.  
  15. int main() {
  16.  
  17. cout<<"BOP"<<endl;
  18.  
  19. {
  20.  
  21. auto ptr1 = make_shared<Test>();
  22.  
  23. ptr1->ptr = ptr1;
  24.  
  25. }
  26.  
  27. cout<<"EOP"<<endl;
  28.  
  29. return 0;
  30.  
  31. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
BOP
Test c-tor
EOP