//weak ptr : 참조 계수가 없는 스마트 포인터
#include <iostream>
#include <memory>
using namespace std;
struct Node {
int data;
weak_ptr<Node> next;
~Node() { cout << "노드 파괴" << endl; }
};
int main() {
shared_ptr<Node> p1(new Node);
shared_ptr<Node> p2(new Node);
p1->next=p2;
p2->next=p1;
return 0;
}
'Developer > Design Patterns' 카테고리의 다른 글
인터페이스 기반의 객체의 이벤트 처리 (0) | 2014.05.18 |
---|---|
State Pattern (0) | 2014.05.18 |
Proxy Pattern을 이용한 스마트포인터 방식 (0) | 2014.05.18 |
참조계수 방식의 스마트 포인터 (0) | 2014.05.18 |
함수포인터, 함수객체를 사용한 인라인 치환 (0) | 2014.05.18 |