Difference between revisions of "Assignment 3i: Q & A"

From CDOT Wiki
Jump to: navigation, search
Line 1: Line 1:
'''Q: Can you remove an element from the middle of the vector container?''' submitted by Imtiaz Latif
+
'''Q: Can you remove an element from the middle of the vector container?''' submitted by Imtiaz Latif <br>
 +
'''A:''' Yes, by using the Standard Library vector member function erase(), which has two implementations: one, '''iterator erase(iterator postion)''' will erase the element at the passed iterator position, while the other, '''iterator erase(iterator first, iterator last)''' will erase ALL the elements in the specified range.
 +
 
 +
More info here: [http://www.cplusplus.com/reference/stl/vector/erase/ Vector erase()]
 +
 
 +
(Submitted by Kevin Kofler, Team 9)

Revision as of 18:55, 15 November 2012

Q: Can you remove an element from the middle of the vector container? submitted by Imtiaz Latif
A: Yes, by using the Standard Library vector member function erase(), which has two implementations: one, iterator erase(iterator postion) will erase the element at the passed iterator position, while the other, iterator erase(iterator first, iterator last) will erase ALL the elements in the specified range.

More info here: Vector erase()

(Submitted by Kevin Kofler, Team 9)