Re: faq: use position of CList can find the element?
- From: MrAsm <mrasm@xxxxxxx>
- Date: Tue, 03 Apr 2007 09:40:56 GMT
On Tue, 03 Apr 2007 17:07:15 +0800, fcvcnet <fcvcnet@xxxxxxx> wrote:
void fun(POSITION pos)
{
CList <CPoint, CPoint&> copy;
copy.RemoveAll();
//CPoint hh=copylist.GetAt(POSITION(0x004215e4));
POSITION pos1(POSITION(0x004215e4));
CPoint dd=copy.GetNext(pos1); <--- interest thing is here
CPoint jj=copy.GetNext(pos); <--- and here.
//<--- the copy is empty but it still can take correct value of dd and
jj back. It seemed work like pointer.
You are kind of violating the "contract" of CList.
Joe already answered you in very clear form in a previous post:
(Maybe you missed it because the thread subject was changed from your
original subject - with the unusual "faq" - to this:
"Re: use position of CList can find the element?")
<cite author="Joe">
You have to be very careful. The POSITION values are valid only as
long as the elements
still exist, so if there is a deletion or insertion that happens
between the time you
compute these values, they will no longer represet what you think they
do.
</cite>
You did a CList.RemoveAll, so the POSITION values are just "junk".
(Moreover, in your code, you are doing a RemoveAll on a CList
constructed with a default constructor, so the CList is already
empty... I can't understand your code.)
MrAsm
.
- Follow-Ups:
- Re: faq: use position of CList can find the element?
- From: Tom Serface
- Re: faq: use position of CList can find the element?
- From: fcvcnet
- Re: faq: use position of CList can find the element?
- References:
- faq: use position of CList can find the element?
- From: fcvcnet
- Re: faq: use position of CList can find the element?
- From: fcvcnet
- faq: use position of CList can find the element?
- Prev by Date: Re: Where are my events going...
- Next by Date: Re: Dialog editor for 2 languages?
- Previous by thread: Re: faq: use position of CList can find the element?
- Next by thread: Re: faq: use position of CList can find the element?
- Index(es):
Relevant Pages
|