1
0
mirror of https://github.com/ioacademy-jikim/android_framwork synced 2025-06-07 16:06:29 +00:00
ioacademy-jikim f25774ff2e 4
2018-06-14 11:35:54 +09:00

83 lines
1.2 KiB
C++

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