【发布时间】:2011-09-21 05:00:41
【问题描述】:
我正在为一个包含我的“对象”对象指针的 STL 列表而苦苦挣扎。
我声明:
list<Object*> objectlist;
并通过以下方式插入:
this->objectlist.push_back(new Object(address,value,profit));
并尝试像在地图和其他中一样进行迭代:
list<Object*>::iterator iter;
iter = this->objectlist.begin();
while(iter != this->objectlist.end())
{
iter->print();
}
其中 print() 是类 Object 的公共方法;
这里有什么问题?
我无法通过迭代器访问列表中的对象?
【问题讨论】: