shamantou blog site

shamantou@gmail.com

导航

智能指针
#include "stdafx.h"
#include
#include

int _tmain(int argc, _TCHAR* argv[])
{
std::auto_ptrps(new int);
std::cout<<"Hello,world!"< return 0;
}



/*
auto_ptr在memory中声明,使用是需 std::auto_ptr,另外注意的是auto_ptr通过copy构造,不能进行赋值构造,会报错,so
std::auto_ptrps(new int);

*/


std::auto_ptrpBitmap(new CString);
pBitmap->Format(_T("%d"),100);

std::auto_ptr a2(pBitmap);

CString *ss= pBitmap.get();
CString *ss2= a2.get();
pBitmap.reset(a2.get());


注意:pBitmap.reset(a2.get());后,对于a2本身没有影响
<< 面试摘要MITK release >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206 Copyright 2006-2009 | ooplab.org | shamantou@gmail.com | 沪ICP备08011244号 | Some Rights Reserved.