Tuesday, 19 April 2011

Why Sizeof object with empty class is not zero in C++?

My understanding would be creating an object means occupying some memory. No size, no memory, no way to tell it is a object or it is an array of objects in C++. So size of object with empty class should one byte. The value could be 1 or 4 depending on the machine.
I am not sure about C#. It is not difficult to know. I will test tomorrow.

Iterative vs. Recursive Approaches

I always do not like recursion. I will definitely use iteration if there is a way to use it instead of recursion. No theory. I just do not like recursion naturally.
Today the article I read tells that the performance of iteration is much better than recursion. Performance here includes both speed and memory usage. Here is the link http://www.codeproject.com/KB/recipes/Iterative_vs_Recursive.aspx so I will confidently continue to use iteration instead of recursion in my daily work.