auto_ptr 은 동적으로 메모리를 할당 받았을 때 종종 잊어 먹게 되는 free나 delete를 자동으로 처리 해주기 위해서 지원하는 Template함수이다.
[code]
#include <Turboc.h>
#include <string>
#include <iostream>
#include <memory>
using namespace std;
void main()
{
auto_ptr<string> pStr(new string("AutoPtr Test"));
cout << *pStr << endl;
// 프로그램 종료시 자동으로 메모리가 해제 된다.
}
[/code]
[code]
#include <Turboc.h>
#include <string>
#include <iostream>
#include <memory>
using namespace std;
void main()
{
auto_ptr<string> pStr(new string("AutoPtr Test"));
cout << *pStr << endl;
// 프로그램 종료시 자동으로 메모리가 해제 된다.
}
[/code]
'Native > C++' 카테고리의 다른 글
리스트 (list) (0) | 2013.10.02 |
---|---|
벡터 (vector) (0) | 2013.10.02 |
Dev Cpp (Dev C++) 다운로드 (0) | 2013.10.02 |
string 관련 멤버함수 (0) | 2013.10.02 |
stringbuf (Buffer class for file streams) (0) | 2013.10.02 |