Sunday, September 17, 2006 6:45 AM
Why is the size of an Object not zero in C++?
In C++, it is possible to declare a class that contains nothing inside it and then instantiate the class. But the strange thing is that the size of this class is never zero. Ideally, the size of such object is the value of the least positive integer. But why?
The rule is that pointers to two different objects should hold distinct values in C++. If the size of the object becomes zero, what would a pointer point to? Moreover, how can we have two pointers containing different values in this case?
An industry experience of over 10 years. Worked extensibly in Microsoft Technologies. Working in .Net and C# for over 5 years. Skills include,
I am currently working as a Technical Architect in a reputed MNC in Hyderabad, India. I have authored a lot of articles on .NET and its related technologies at ASPALLIANCE, DEVX, ASPNETPRO, CODERSOURCE, SQL-SERVER-PERFORMANCE.COM, SSWUG, etc.
Mail ID: email@example.com
I blog at: http://aspadvice.com/blogs/joydip/