【问题标题】:Iterating through boost ptr_vector迭代 boost ptr_vector
【发布时间】:2010-05-26 16:49:32
【问题描述】:

我有一个我自己的对象的 ptr_vector 列表。像这样的:

boost::ptr_vector<SomeClass> *list;
list->push_back(new SomeClass()>;
...
BOOST_FOREACH(SomeClass *tempObj, list)   // [x]
{
   tempObj->...
}


>‘boost::ptr_vector<SomeClass>*’ is not a class, struct, or union type

【问题讨论】:

    标签: boost loops ptr-vector


    【解决方案1】:

    认为您的问题是您将“list”声明为指向 boost::ptr_vector 的指针,并试图将其用作自动对象。

    恕我直言,您的代码 sn-p 的第一行应为:

    boost::ptr_vector<SomeClass> list;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多