【发布时间】:2009-10-14 11:33:09
【问题描述】:
如果我有一个list<object*>>* queue 并且想弹出列表中的第一个对象并将其交给程序的另一部分,使用是否正确(粗略代码):
object* objPtr = queue->first();
queue->pop_first();
return objPtr; // is this a pointer to a valid memory address now?
?
根据http://www.cplusplus.com/reference/stl/list/pop_front/ 上的文档,它调用了已删除元素的析构函数,但我很困惑它是指链表的节点对象,还是实际存储的“用户”对象。
编辑:我可能是front 而不是first,我的错。
【问题讨论】:
标签: c++ list stl pointers object