Re: assignment operator and CList
- From: "AliR" <AliR@xxxxxxxxxxxxx>
- Date: Wed, 13 Jul 2005 15:44:58 -0500
Have you tried making a call to one of the object in your list yet?
What is going to happen here is that the destructor of the button destroys
the button. So if the orginal object that you call AddTail or AddHead with
goes out of scope then the button is destroyed. Here is another thing, even
if you keep the original instances of the objects around, then when you go
to empty the list the objects will destroy the buttons, then when the
originals go out of scope they will also want to destroy the button window.
Good luck
AliR.
"zorman" <bulba@xxxxxxxxx> wrote in message
news:uJJvbd%23hFHA.1244@xxxxxxxxxxxxxxxxxxxxxxx
> well it's funny, but I "faked" copy constructor and assignment operator
like
> these:
> CButtonX operator=(CButtonST obj);
> CButtonX(const CButtonX &ob) {TRACE("Copy constructor called.\n");}
> CButtonST CButtonST::operator=(CButtonST obj)
> { return *this;}
>
> and it's working, although not sure if this is safe solution...
> Maybe like you saying create them on the heap would be better.
>
>
>
> "Heinz Ozwirk" <hozwirk.SPAM@xxxxxxxx> wrote in message
> news:42d571a9$0$20133$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > "zorman" <bulba@xxxxxxxxx> schrieb im Newsbeitrag
> > news:%234ALHK%23hFHA.1708@xxxxxxxxxxxxxxxxxxxxxxx
> >> The problem is that I want to store whole objects not pointers, because
> >> original objects will be lost.
> >> CButtonX is just customized CButton class.
> >> thanks
> >
> > CButton, like all classes derived from CObject are not copy-constuctable
> > or assignable. You cannot store them in lists (or any other container).
> > All you can do is create them on the heap (using new) and store pointers
> > into the list. Of cause, before you remove a pointer from the list, you
> > must either make (and keep) a copy of that pointer or destroy the
object.
> >
> > Heinz
> >
>
>
>
.
- Follow-Ups:
- Re: assignment operator and CList
- From: zorman
- Re: assignment operator and CList
- References:
- assignment operator and CList
- From: zorman
- Re: assignment operator and CList
- From: AliR
- Re: assignment operator and CList
- From: zorman
- Re: assignment operator and CList
- From: Heinz Ozwirk
- Re: assignment operator and CList
- From: zorman
- assignment operator and CList
- Prev by Date: Re: assignment operator and CList
- Next by Date: Inserting Icons in ToolBars
- Previous by thread: Re: assignment operator and CList
- Next by thread: Re: assignment operator and CList
- Index(es):