列表的最后一个元素 [英] last element of list
问题描述
我正在尝试创建一个函数,它将一个对象插入一个列表并返回
一个迭代器到列表中的新元素。但据我所知,没有
函数可以将迭代器返回到列表的最后一个元素。 (.end()
在列表末尾返回一个迭代器项目)我怎么能解决
这个?
I''m trying to make a function which insert an object into a list and returns
an iterator to the new element in the list. But as far as I know there is no
function which returns an iterator to the last element of a list. (.end()
returns an iterator one item past the end of the list) How could I solve
this?
推荐答案
" xerix" schrieb
"xerix" schrieb
我正在尝试创建一个将对象插入列表的函数,
返回一个迭代器到列表中的新元素。但据我所知,有
没有函数将迭代器返回到列表的最后一个元素。 (.end()
返回一个迭代器,一个项目超过列表的末尾)我怎么能解决这个?
I''m trying to make a function which insert an object into a list and returns an iterator to the new element in the list. But as far as I know there is no function which returns an iterator to the last element of a list. (.end()
returns an iterator one item past the end of the list) How could I solve
this?
try std: :list< T> :: back()并确保你的清单不是空的
Arne
try std::list<T>::back() and make sure that your list is not empty
Arne
" xerix" ; schrieb
"xerix" schrieb
我正在尝试创建一个将对象插入列表的函数,
返回一个迭代器到列表中的新元素。但据我所知,有
没有函数将迭代器返回到列表的最后一个元素。 (.end()
返回一个迭代器,一个项目超过列表的末尾)我怎么能解决这个?
I''m trying to make a function which insert an object into a list and returns an iterator to the new element in the list. But as far as I know there is no function which returns an iterator to the last element of a list. (.end()
returns an iterator one item past the end of the list) How could I solve
this?
try std: :list< T> :: back()并确保你的清单不是空的
Arne
try std::list<T>::back() and make sure that your list is not empty
Arne
" Arne Adams" <在*** @ arneadams.com>在消息中写道
news:c5 ************* @ news.t-online.com ...
"Arne Adams" <in***@arneadams.com> wrote in message
news:c5*************@news.t-online.com...
" xerix" schrieb
"xerix" schrieb
我正在尝试创建一个将对象插入列表并将
I''m trying to make a function which insert an object into a list and returns
迭代器返回到列表中的新元素的函数。但据我所知,
不是
an iterator to the new element in the list. But as far as I know there is no
函数,它将迭代器返回到列表的最后一个元素。
function which returns an iterator to the last element of a list.
(.end()返回一个迭代器,一个项目超过列表的末尾)我怎么能解决这个?
(.end() returns an iterator one item past the end of the list) How could I solve
this?
尝试std :: list< T> :: back ()并确保你的清单不是空的
Arne
try std::list<T>::back() and make sure that your list is not empty
Arne
返回对最后一个元素的引用列表,但我需要一个
迭代器到列表的最后一个元素。
back returns a reference to the last element from the list, but I need an
iterator to the last element of the list.
这篇关于列表的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!