fork download
  1. #include <stdio.h>
  2.  
  3. class A {
  4. bool m_init;
  5. public:
  6. A(){m_init = true; printf ("ctor\n");}
  7. ~A(){
  8. printf ("dtor\n");
  9. if (m_init) {
  10. deinit();
  11. }
  12. }
  13.  
  14. void deinit () {
  15. printf ("deinit!\n");
  16. m_init = false;
  17. }
  18. };
  19.  
  20. int main() {
  21.  
  22. A a;
  23. a.~A();
  24. return 0;
  25. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
ctor
dtor
deinit!
dtor
deinit!