Thanks for your input.While I understand what you are saying at face value, I am not sure what impact is has on my code as written. How do I avoid 'dynamically allocating memory'? Do you mean, that the less amount of formal parameters that I declare, the better? Or is there more to it than that?
What does it mean "to rely on the caller to free it"? (I am new at all this.) So if within a function I declare a local object double someArray
and then I call the function from within main()
, it allocates enough memory for the array. When it returns from the function, does it not automatically deallocate the memory?
I like it. You are right that the RHS is no longer needed within the function and so it could be overwritten.