Sure, you can use heap objects whenever you want, but you can't escape from the fact that when you do, you'll also be introducing potential bugs in your code, beucase those objects must be freed,...
Type: Posts; User: Elysia
Sure, you can use heap objects whenever you want, but you can't escape from the fact that when you do, you'll also be introducing potential bugs in your code, beucase those objects must be freed,...
Of course you should use heap objects when you need them, but the general idea is to avoid them IF you don't need them. What you don't create, you don't need to free.
Wow. Good advice. I'll...
Of course, that's what I mean. If the memory is to be freed, let it (if possible) be the function that allocated it. If it must outlive the function, consider setting rules for how. Is it a function...
Yes, you should use thoroughly tested objects rather than making your own to avoid memory leaks. Using vectors instead of arrays is a good thing to make sure you don't get leaks.
There are, of...
Use memory managers or shared pointers, such as boost's shared_ptr, define responsibility for who should clean up the memory and make common exit sections in functions so that everything is cleaned...