Home

On Aug 24, 12:33 pm, tom <pxk...@gmail.com> wrote:
>
> Thanks a lot for your answer. Your advice rocks.
> To deal with problem, I think I could only fall back to dynamic memory
> allocation and reference counter or smart pointer.(Though it's not a
> good idea to put it in a container here in this scenario)- Hide quoted text -
>

To put it another way, when programming with containers it's always a
good idea to have a clear picture of who *owns* the contained data
(as opposed to merely referencing it). With this in place, you can
ensure that destruction happens correctly without having to revert to
smart pointers/reference counting. Many folks will tell you that it's
better/safer to use smart pointers anyway, but often just getting
this
ownership issue straight in your head (and in the code!) is
sufficient.

previous
next

Re: getopt with negative numbers?
how to define const double in a templated class
Re: Returning (char *) from a function - memory problem
Re: append data to a vector
Re: Assigning values to a struct
Mimo Wszystko
Fundacja Sloneczko
Niechciane i Zapomniane
Rodzic Po Ludzku
Fundacja Iskierka