From: Per W. <pw...@ia...> - 2006-08-21 16:00:40
|
I don't know what you did expect. First of all, there are no standard that tells how muh extra data that a compiler should/may add to the size of an object. Extra data is needed for RTTI, virtual methods etc. One other important factor is the avoidance of zero-size objects. Let's say that you have an object of zero size. Then you allocate an array of 100 such objects. How would you now iterate through the array? If the object has zero size, each element of the array would have the same address since the whole array would be zero size. /Per W On Mon, 21 Aug 2006, karunakar A.K. wrote: > Dear All > > Output of the following program is 1. Please explain me the reason. > > > with regards > karunakar > > > > > #include <iostream.h> > #include <conio.h> > > class Object > { > public: > Object() { } > }; > void main() > { > cout << "\nSize = " << sizeof(Object); > } > > > --------------------------------- > Here's a new way to find what you're looking for - Yahoo! Answers > Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW |