Program Language/C & C++
[C++] unique_ptr 동적 할당 및 해제 하기
야곰야곰+책벌레
2022. 5. 18. 17:26
728x90
반응형
class Temp
{
public:
Temp() {}
~Temp() {}
};
unique_ptr을 동적 배열 적용
unique_ptr<Temp[]> unqTemp(new Temp[2]);
unique_ptr<Temp[]> unqTemp = make_unique<Temp[]>(2);
auto unqTemp2 = move(unqTemp);
uinque_ptr 메모리 해제
unique_ptr<Temp> unqTemp(new Temp);
unqTemp.reset(nullptr);
728x90
반응형