스마트 포인터(smart pointer)


스마트 포인터(smart pointer)

스마트 포인터(smart pointer) : 메모리에 동적으로 할당한 객체를 해당 구문이 끝날 쯤에 자동으로 회수하는 방법. 실수를 줄여준다. (신경쓸게 줄어든다) Colored By Color Scripter 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 #include <iostream> using namespace std; class Point { int x; int y; public: Point(int _x = 0, int _y = 0) :x(_x), y(_y) {} void Print() const { cout << x << ',' << y << endl; } }; class PointPtr { Point *ptr; public: PointPtr(Point* p) :ptr(p) {} ~PointPtr() { del...


#smartpointer

원문링크 : 스마트 포인터(smart pointer)