我遇到了一个问题,想知道是否有人可以帮助我。
在我的一节课中(例如 class1)我有一个
typedef boost::shared_ptr <class-one-object>
typedef std::vector<class-one-object>
在另一个类(例如 class2)中,我需要再次创建一个 vector ,以便遍历这个
class-one-object
所以我正在尝试以下
class1::ImportTableObject& table = configPtr->getTable();
std::vector<class1::class-one-object>::const_iterator* iter = table.begin();
这引发了以下编译错误:
cannot convret `__gnu_cxx::__normal_iterator<boost::shared_ptr<class1::class-one-object>*, std::vector<boost::shared_ptr<class1::class-one-object>,
std::alloctor<boost::shared_ptr<class1::class-one-object> > > to '__gnu_cxx::__normal_iterator<const class1::class-one-object*, std::vector<class1::class-one-object>
等等等等
谁能帮帮我?
提前谢谢你
最佳答案
begin
不返回指向迭代器的指针,它返回一个迭代器。
std::vector<class1::class-one-object>::const_iterator iter = table.begin()
应该可以解决问题。
关于c++ - 创建一个由 boost 共享指针组成的 vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10494682/