書式#include <文字列>
の#include <fstreamの>
の#include <メモリ>
書式#include <cstdioを>
クラスFileDeleter
{
プライベート:
STD ::文字列のファイル名。
公共:
FileDeleter(CONSTのstd ::文字列&FN)
:ファイル名(FN){}
ボイド演算子()(STD :: ofstreamのの*のFP){
FP->近いです();
std ::削除(filename.c_str());
}
}。
メインINT()
{
のstd :: shared_ptrの<のstd :: ofstreamの> FP(新しいSTD :: ofstreamの( "tmpfile.txt")、FileDeleter( "tmpfile.txt"));
}