c++11

智能指针,不用手动删除

#include <memory>       //For STL auto_ptr class

 

std::auto_ptr<TStringList>list(new TStringList());

 list->Strings[3];

 

std::auto_ptr<TStringList>sl(new TStringList());

sl->访问成员

sl.get();需要用到指针的时候

 

ListBox1->Items->AddStrings(sl.get());否则不成功

 

 ListBox1->Items->AddStrings(sl);/error change to down
    std::auto_ptr<TStringList>sl(new TStringList());
    sl->Add("a");
    sl->Add("b");
    ListBox1->Items->AddStrings(sl.get());

 

 

std::auto_ptr<TList>LocList(new TList);

 

 

std::auto_ptr<TEdit>et(new TEdit(this));
et->Text = ListBox1->Items->Text;
et->CopyToClipboard();

 

 

std::auto_ptr<TFDMemTable> table (new TFDMemTable(NULL));