首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

智能指定的转换有关问题

2013-09-12 
智能指定的转换问题接口返回auto_ptrstd::auto_ptrclasssObj tmp1getOBj(***)后面需要用到,但要求类型

智能指定的转换问题
接口返回auto_ptr
std::auto_ptr<classsObj> tmp1=getOBj(***)
后面需要用到,但要求类型为boost::shared_ptr,所以想把它保存到map中
std::map<string,boost::shared_ptr<classsObj>> ComMocList;
ComMocList.insert("test1",boost::shared_ptr<classsObj>(tmp1.release())));

接口类型无法改动。这样使用会core。是否只能重新生成boost::shared_ptr类型的类对像?类很大,最好不要这样做,请问还有其它方法吗

[解决办法]
这里看没有问题样. 中间使用的时候有没有把 tmp1 赋值给其它的变量吧? 或者做为参数传递给其它函数?

热点排行