Is this safe?
My computer is broken, so I can't test this; is it safe to delete this; on a class that may or may not have been allocated with new? For example:
void Bake(unsigned int);
delete this; // May/may not have been allocated with new
...So if it wasn't allocated with new, I shouldn't do it?
Dammit... alright, and thanks for the eerily instantaneous reply o.0
If you can explain why you were wanting to do that we may have an alternative strategy.
actually, what you have there is an infinitely recursive situation. delete always calls the destructor, which calls delete, etc. if you created an object of that type on the stack in a function, the function would never return because as that object went out of scope, the destructor would get called, and try to delete itself. you would eventually run out of stack space and definitely crash. the only way your code will work, is if you allocate with new, and never EVER use delete on those objects.