Original Post
Crap, I just had this big long post, and the browser ate my submission.
Anyway, ok...I have an Obj that is supposed to live it's life for a set time and then go away. I have an ObjMgr class that manages all the Objs, updating them and releasing them when they're dead. I guess the best way to describe my problem is with a small example:
main ()
{
init ();
while (!done)
{
Obj ball (10); //ball that bounces on screen for 10
seconds, this call will work fine
update (); //this is where ObjMgr updates
}
shutdown ();
}
//let's say this function gets called when a button is clicked
void func ()
{
Obj ball (5); //a ball bounces on screen for 5 s
this gives me nothing
}
Ok my logic tells me that it gives me nothing because it's created, then the function ends, and the Obj falls out of scope and deletes itself. Not good. Is there a way I can make them stick around until they live out their lifespan without caring where they were called? If I change the call to:
Obj* ball = new Obj (5);
It works, but it's a memory leak. So that means everything is working, just that the Obj isn't static, but it can't be static, because I might want to press the button a few times and create different bouncing balls each time....Can anyone spare some advice? Thanks
-------------------------------------------
The Lord will fight for you; you need only to be still.
Exodus 14:14
[edited by - pacman on October 9, 2003 6:38:19 PM]