fork(1) download
  1. #include <iostream>
  2.  
  3.  
  4. struct data
  5. {
  6. ~data() { std::cout << "data: destructor\n"; }
  7. };
  8.  
  9.  
  10. struct sample
  11. {
  12. //data value;
  13. int value;
  14.  
  15. ~sample() { std::cout << "sample: destructor\n"; }
  16. };
  17.  
  18.  
  19. int main()
  20. {
  21. std::cout << "begin...\n";
  22. {
  23. const auto& ref = sample().value;
  24. std::cout << "work with temporary...\n";
  25. }
  26. std::cout << "finished!\n";
  27.  
  28. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
begin...
sample: destructor
work with temporary...
finished!