[LC++]temporals objects
Paul Carter
pacman128 at hotmail.com
Wed Jan 2 20:35:47 UTC 2002
On Thu, Dec 20, 2001 at 06:02:29PM +0100, Julien Patrick Claassen wrote:
> Hello!
> As you are so worried about this problem, I think it should be
> integrated in a bigger program. So why not just do:
> OtherClass *b;
> and anywhere you need an object of type OtherClass you can do:
> b = new OtherClass("this");
> a.push_back(b);
> delete b;
This is NOT a good idea. "a" now has a pointer to memory that has been
deallocated. Undefined behavior will follow.
>
> I think that will be some more code to write in your main-program, but
> it would work, I suppose.
> Kindest regards
> Julien
>
--
Paul Carter [http://www.drpaulcarter.com/]
More information about the tuxCPProgramming
mailing list