View Single Post
Old 05-25-2005, 06:49 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Code:
listiter->
is not defined by the standard. Do...
Code:
(*listiter).
offtopic tip

Don't do...
Code:
listIter < this->elementList.end( )
...in the for-loop. At every iteration, end() needs to be recalculated.
Do:
Code:
std::vector<element*>::iterator ItEnd;
ItEnd = elementList.end( );
for (listIter = elementList.begin( ); listiter != ItEnd; ++listIter)
{ }
- Observe !=.
Any iterator it < vector::end() is undefined since end() is a pointer *past* the last element. So this comparison makes technically no sense.
- Observe ++listiter
Your element object *may* create an internal temporary object and therefore *may* add runtime overhead due to copy constructor calls and destructor calls. Using the pre-increment operator prevents this.
__________________
Valmont is offline   Reply With Quote