使用auto_ptr<>带阵列 [英] Using auto_ptr<> with array

查看:77
本文介绍了使用auto_ptr<>带阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用auto_ptr<>,它使用类指针类型的数组,因此如何为它分配一个值.

I'm using auto_ptr<> which uses an array of class pointer type so how do I assign a value to it.

例如 auto_ptr<class*> arr[10];

如何为arr数组分配值?

推荐答案

您不能将auto_ptr与array一起使用,因为它会调用delete p而不是delete [] p.

You cannot use auto_ptr with array, because it calls delete p, not delete [] p.

您要 boost :: scoped_array 或其他一些boost :: smart_array :)

You want boost::scoped_array or some other boost::smart_array :)

这篇关于使用auto_ptr&lt;&gt;带阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆