Sección 2. Capítulo 3
single
Challenge: Forward Iterator Traversal
Desliza para mostrar el menú
Tarea
Swipe to start coding
Implement the function advance_forward that advances a given std::forward_list<int>::iterator by a specified number of steps using only forward traversal. You must not use --, std::advance, or any reverse traversal.
- Accept a
std::forward_list<int>::iteratorand an integerstepsas parameters. - Move the iterator forward by
stepsusing only++it. - Return the resulting iterator.
- Do not use
--,std::advance, or any other methods that allow reverse or random access. - If the end of the list is reached before completing all steps, return the end iterator.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 3
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla