Are we able to convert a std::auto_ptr to a normal pointer??
class Test
{
......
}
Test* function()
{
std::auto_ptr<Test> test(new Test());
return _____//TODO : need to convert this auto_ptr to Test*
}
Is it possible to convert an auto_ptr pointer which is created locally to normal pointer.
Use release()
Test* function()
{
std::auto_ptr<Test> test(new Test());
return test.release()
}
Is it possible to convert an auto_ptr pointer which is created locally to normal pointer.
Yes:
return test.release();
请参阅std :: auto_ptr的发布方法: http ://www.cplusplus.com/reference/std/memory/auto_ptr/release/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.