I see what you are saying, the classes with ZeroThis in the Init are not static / stack variables, or variables in another class.Solar wrote:It is much worse than that.
Once the object has been constructed, that means all the member constructors have been run as well.
Then he just slaps zeroes on top of it all.
When the object goes out of scope, the destructors will run, assuming well-formed member instances.
This is desaster waiting to happen. It might work for the POD type he is working with now, but as soon as any of his constructors do any significant work, it will blow up.
Init() and memset() are the very things C++ objects were meant to REPLACE....
They are only created using memory allocation directly.
None of the classes will go out of scope, no destructors are ever called.
But yes, very good points, terrible way of doing it.
How would you automatically zero all the properties in a class?
Or how would you automatically add 0xDEADBEEF?
Ali