fork download
  1. import std.stdio;
  2.  
  3. class A {
  4. public:
  5. void print() { writeln( "a" ); }
  6. ~this() { /*b.print();*/ }
  7. B b;
  8. }
  9.  
  10. class B {
  11. public:
  12. void print() {/*writeln( "b" );*/ }
  13. ~this() { a.print(); }
  14. A a;
  15. }
  16.  
  17.  
  18. int main( char[][] arg )
  19. {
  20. A a = new A();
  21. B b = new B();
  22. a.b = b;
  23. b.a = a;
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 2120KB
stdin
Standard input is empty
stdout
a