O
Olumide
Hello,
To begin with, I'm no STL expert. I've only just begun to use and
appreciate the power of STL.
Okay, so I have a list:
list<int> myLuckyNumbers;
list<int>::iterator intList_Iterator = myLuckyNumbers->begin();
while( intList_Iterator != myLuckyNumbers->end() )
{
int *integerPointer = &(*intList_Iterator);
intList_Iterator++;
}
In order to get a pointer to each element of the list, I need to use
the unintuitive expression, &(*intList_Iterator). My worry is that
because the dereference (*) and "address of" (&) operators, cancel
each other, shouldn't intList_Iterator be interpreted as a pointer to
a int, if assigned to an int?
Also, is there a better way getting the pointer to the current in in
the list?
Thanks,
- Olumide
To begin with, I'm no STL expert. I've only just begun to use and
appreciate the power of STL.
Okay, so I have a list:
list<int> myLuckyNumbers;
list<int>::iterator intList_Iterator = myLuckyNumbers->begin();
while( intList_Iterator != myLuckyNumbers->end() )
{
int *integerPointer = &(*intList_Iterator);
intList_Iterator++;
}
In order to get a pointer to each element of the list, I need to use
the unintuitive expression, &(*intList_Iterator). My worry is that
because the dereference (*) and "address of" (&) operators, cancel
each other, shouldn't intList_Iterator be interpreted as a pointer to
a int, if assigned to an int?
Also, is there a better way getting the pointer to the current in in
the list?
Thanks,
- Olumide