-
Notifications
You must be signed in to change notification settings - Fork 1
/
test4.cpp
81 lines (71 loc) · 1.41 KB
/
test4.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*=============================================================================
#
# FileName: test4.cpp
# Desc: 测试一下ptr_proxy
#
# Author: dantezhu
# Email: [email protected]
# HomePage: http:https://www.vimer.cn
#
# Created: 2011-06-13 15:47:32
# Version: 0.0.1
# History:
# 0.0.1 | dantezhu | 2011-06-13 15:47:32 | initialization
#
=============================================================================*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <iostream>
#include <memory>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include "ptr_proxy.h"
using namespace std;
class A : public IPtrProxy<A>
{
public:
A() {}
virtual ~A() {}
};
class B : public IPtrProxy<B>
{
public:
B() {}
virtual ~B() {}
void print()
{
printf("this is print\n");
}
void SetAPtr(const ptr_proxy<A>& pptr)
{
m_ptr_a = pptr;
}
void check()
{
if (m_ptr_a.is_null())
{
printf("is null\n");
}
else
{
printf("is not null\n");
}
}
ptr_proxy<A> m_ptr_a;
};
int main(int argc, char **argv)
{
A* a = new A();
B* b = new B();
b->SetAPtr(a->get_ptr_proxy());
delete a;
b->check();
b->get_ptr_proxy().true_ptr()->print();
delete b;
return 0;
}