#include <stdio.h>
class Y;
class X {
public:
        X() { printf("X()\n"); }
        X(Y *obj) : m_obj(obj) { printf("X(Y *obj)\n"); }
        ~X();
        Y *m_obj;
};
class Y {
public:
        Y() { printf("Y()\n"); }
        Y(X *obj) : m_obj(obj) { printf("Y(X *obj)\n"); }
        ~Y() { delete m_obj; printf("~Y()\n"); }
        X *m_obj;
};
// X's destructor impl here
X::~X() {
        delete m_obj;
        printf("~X()\n");
}

int main() {
        printf("main()\n");
        X(new Y(new X(new Y(new X))));
};