Hi all,
need to ask quick question about stl linked lists.
When i push objects into a list am i correct in saying that on each push
"new" objects are created i.e. the linker fixes addresses for those objects in the container.
While the address for those objects in the container are different the value they hold are "copied" from the object that was pushed in.
So if i have
Code:
class myClass
{
int a ;
myClass()
{
a =10 ;
}
}
myClass a ;
list <myClass> ;
myClass.push_back(a) ;
the member variable a for the new objects in the list would have the value 10 unless changed.
So is my logic flawed?
Sorry for this ridiculous question. I had to use linked lists all of a sudden, so have to read it on my own.
The main question though is the erase function using an iterator.
Code:
while(it!=myClass.end())
{
if(....)
{
it= myClass.erase() ;
}
}
why do we need to initialize it to myClass.erase()
what does erase() return?
would not do if we just increment it?
so
Code:
myClass.erase()
it++ ;
in a hurry, sorry if formatting is bad.
Thanks in advance