|
|
(THE BOOK SAYS::Also note that when we do create a Monster, dynamic memory must be used so that the system does not automatically destroy the memory when the function returns). |
(THE BOOK SAYS::Also note that when we do create a Monster, dynamic memory must be used so that the system does not automatically destroy the memory when the function returns). |
It's true to say that it could return an instance - but obviously that becomes less efficient as the size of the object increases - also polymorphism of the object cannot be achieved using that approach. Depending on the situation it does make sense though. |
This statement: (THE BOOK SAYS::Also note that when we do create a Monster, dynamic memory must be used so that the system does not automatically destroy the memory when the function returns). is sort of a non-sequitur and is therefore misleading. I could read this statement to mean that functions may ONLY return pointers, and that is untrue. |
C++ gives me too much that I now take for granted. |
whenever there is a proven memory leak (which is proven by statistical analysis only, by watching memory utilization over literally days of run time) it always takes weeks and weeks to track it down. |