this is my code:
for (list<moveStringTree>::iterator tempIterator=moveList.begin();tempIterator!=moveList.end(); ++tempIterator)
{
moveStringTree *move = tempIterator;
}
but it gives me an error. if there is a castingway, I don’t like it. it is too time consuming. anyway I want to go throw a list and do something with each object in it. what can I do?
foreach won’t help. because only it will give a copy.
It is. An object in C++ is equivalent to a memory location holding a value – no more, no less. However, I don’t see how this relates to the rest of the question.
I have no idea what this means. But just in case you meant copy: no, it’s probably not too time-consuming. But if it is – don’t worry; use a reference.
Nonsense. foreach does the same as manually iterating. So you can also use it with a copy: