Re: std::vector : begin, end and insert - Using Objects instead of ints
- From: "Nobody" <Nobody@xxxxxxxxx>
- Date: Wed, 11 Apr 2007 04:19:36 -0700
I can't paste plain text. Only formats using html.
I'll have to figure that out.
Better using "++m_Iter".I am just used to the way I have always done it.
And "m_Iter != m_Pts.end()"
But thanks for the FYI.
for ( m_Iter = m_Pts.begin();Cool. That looks like the solution!
m_Iter != m_Pts.end();
++m_Iter )
{
TRACE("Pt: x = %d, y = %d\n",
(*m_Iter).x, // (*m_Iter) <-> CPoint
(*m_Iter).y
);
}
I didn't know what to do without the int and CPoint not being size_type.
The examples only work with ints.
So you can have e.g. PointList::iterator, which is IMHO more readable,This is just a test.
more elegant and shorter than std::vector<CPoint>::iterator.
I don't want to add more than is necessary, but thanks.
That is why I commented it out.std::vector<CPoint>::const_iterator m_cIter;
// *c1_cIter = 200; Error. c1_cIter is constant.
Because: 1) you used a const_iterator [try using iterator if you want
to modify objects]; 2) your iterators are not int's.
It is just there to show the error. Just like the doc does.
I know it is wrong. That is why I posted the question.m_cIter = m_Pts.begin();
TRACE("Position of Iterator: %d\n", *m_cIter);
This is wrong.
Please understand that *Iter in this case is a CPoint instance (or
I realized that when I change the x value for CPoint.
It was displaying CPoint.x for *Iter.
I said in my first post, that it seemed to work just like front.
begin == front?
begin is used as an iterator. That seems to be the only difference.
*Now, all I have to do is get by the insert problem.
CPoint pt(1,2);
m_Pts.insert(Pt, m_Pts.begin()+1, m_Pts.begin()+2);
How do I insert it?
Thanks,
.
- Follow-Ups:
- References:
- std::vector : begin, end and insert - Using Objects instead of ints
- From: Nobody
- Re: std::vector : begin, end and insert - Using Objects instead of ints
- From: David Lowndes
- Re: std::vector : begin, end and insert - Using Objects instead of ints
- From: Nobody
- Re: std::vector : begin, end and insert - Using Objects instead of ints
- From: MrAsm
- std::vector : begin, end and insert - Using Objects instead of ints
- Prev by Date: Re: Crash: HEAP: Free Heap block modified...
- Next by Date: Re: Embed Powerpoint window inside window / dialog
- Previous by thread: Re: std::vector : begin, end and insert - Using Objects instead of ints
- Next by thread: Re: std::vector : begin, end and insert - Using Objects instead of ints
- Index(es):
Relevant Pages
|