----------------------------------------------------------- New Message on BDOTNET
----------------------------------------------------------- From: Pandurang_Nayak Message 4 in Discussion Hi Sujay, MSDN Documentation says: When the sizeof operator is applied to a class, struct, or union type, the result is the number of bytes in an object of that type, plus any padding added to align members on word boundaries. The result does not necessarily correspond to the size calculated by adding the storage requirements of the individual members. The <MSHelp:link tabIndex=0 keywords="_core_.2f.Zp">/Zp</MSHelp:link> compiler option and the <MSHelp:link tabIndex=0 keywords="_predir_pack">pack</MSHelp:link> pragma affect alignment boundaries for members. The sizeof operator never yields 0, even for an empty class. rgds Pandurang -----Original Message----- From: Sujay [mailto:[EMAIL PROTECTED] Sent: Monday, July 21, 2003 7:09 PM To: BDOTNET Subject: [OT] -- sizeof operator question New Message on BDOTNET [OT] -- sizeof operator question Reply Reply to Sender Recommend Message 1 in Discussion From: Sujay Hello Users , I am posting an off topic question I have an empty class, like below :- class MyClass { // Nothing }; int main( ) { MyClass obj; int nSize = sizeof(obj); cout << size << endl ; // The value gets printed as 1 } Though the class is empty , the sizeof operator returns 1. My question is WHY ? On the other hand if I declare a int member variable in the class, sizeof returns the value of the int only. Any help would be appreciated . Sujay Sujay Ghosh iGATE Global Solutions Ltd., ( formerly known as Mascot Systems Ltd.), No.1, Main Road , Jakkasandra , Off Sarjapur Road , Koramangala Extn . Bangalore - 560 034 Mail : [EMAIL PROTECTED] Phone : + 91 - 080 - 552 - 1701 - 06 ( Extn : 5010) Fax : 91-080-5521704 Mobile : 98454 67789 View other groups in this category. ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/BDotNet/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
