Re: std::vector : begin, end and insert - Using Objects instead of ints
I thought I would experimenting with vectors.
I am trying to use CPoint objects instead the examples, which use ints.
So, I am a having a few problems.
Question 1.
How do I get the integer value from _Iter
What integer value?
or
How do I use _Iter to get the object?
*_Iter
for (_Iter = pt.begin(); _Iter < pt.end(); _Iter++)
{
CPoint& pt = Pts.at(??);
}
I am not sure about the use of begin and end.
You'd normally write:
for ( _Iter = pt.begin(); _Iter != pt.end(); ++_Iter )
Would 0 and size() be the equivalents?
For the purpose of writing a loop - they'd have the same end result.
Would there ever be a difference between them?
Yes, there's no guarantee that an iterator is an index or a pointer;
How do I go about adding CPoint objects with insert?
Do I have to add the object to the front or back of the list,
then move it to the correct position, then delete it from the list?
No. There's an example in MSDN with the insert method documentation.
/*** Code start ****/.
.... and has come out unreadable for me.
Dave