Hello,
I am working on a game using SDL. I was pointers to some 2d primitives, however probably to bad management there were some memory leaks. I switched to use references and not allocate dynamic memory. I believe the problems were due to not following the rule of 3 (not declaring explicitly the assignment operator).
So, my questions is: should I try to avoid dynamic memory allocation. For example, I know that some object is needed in the scope of a function or that it should last for a very very brief period where a few functions have to work on it. Should I in this case pass by reference or by pointer to the object?
What do you think?
To me, it seems that dynamic memory allocation is helpful only when one has to create an array where the size of the array is not known.
I would be grateful if you give some hints and point out when they would be definitely necessary to be used.