#if 1 #include #include #include using namespace android; class AAA; class BBB; class AAA : public virtual RefBase { public: wp pb; AAA(){ printf("AAA::AAA()\n"); } ~AAA() { printf("AAA::~AAA()\n"); } void foo() { printf("AAA::foo()\n"); } }; class BBB : public virtual RefBase { public: wp pa; BBB(){ printf("BBB::BBB()\n"); } ~BBB() { printf("BBB::~BBB()\n"); } void foo() { printf("BBB::foo()\n"); } }; int main() { { sp p1 = new AAA; sp p2 = new BBB; p1->pb = p2; p2->pa = p1; } return 0; } #endif #if 0 #include #include #include using namespace android; class AAA; class BBB; class AAA : public virtual RefBase { public: sp pb; AAA(){ printf("AAA::AAA()\n"); } ~AAA() { printf("AAA::~AAA()\n"); } void foo() { printf("AAA::foo()\n"); } }; class BBB : public virtual RefBase { public: sp pa; BBB(){ printf("BBB::BBB()\n"); } ~BBB() { printf("BBB::~BBB()\n"); } void foo() { printf("BBB::foo()\n"); } }; int main() { { sp p1 = new AAA; sp p2 = new BBB; p1->pb = p2; p2->pa = p1; } return 0; } #endif