【发布时间】:2010-06-01 19:40:12
【问题描述】:
我有一个具有 tr1::shared_ptr 作为成员的类,如下所示:
class Foo
{
std::tr1::shared_ptr<TCODBsp> bsp;
void Bar();
}
在成员函数 Bar 中,我尝试这样分配它:
bsp = newTCODBsp(x,y,w,h);
g++ 然后给我这个错误
no match for ‘operator=’ in ‘((yarl::mapGen::MapGenerator*)this)->yarl::mapGen::MapGenerator::bsp = (operator new(40u), (<statement>, ((TCODBsp*)<anonymous>)))’
/usr/include/c++/4.4/tr1/shared_ptr.h:834: note: candidates are: std::tr1::shared_ptr<TCODBsp>& std::tr1::shared_ptr<TCODBsp>::operator=(const std::tr1::shared_ptr<TCODBsp>&)
在我的代码中,Foo 实际上是yarl::mapGen::MapGenerator。我做错了什么?
【问题讨论】:
标签: c++ variable-assignment shared-ptr