fork download
  1. #include <iostream>
  2.  
  3. struct ABC{
  4. int A;
  5. ABC(int i = 1) : A(i) {}
  6. ~ABC() {
  7. std::cout << A << std::endl;
  8. }
  9. void destruct() {
  10. delete this;
  11. }
  12. };
  13.  
  14. int main() {
  15. ABC *A1 = new ABC(2);
  16. A1->destruct();
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
2