Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Integrity Servers: HP aC++/HP ANSI C Release Notes > Chapter 4 Compatibility Information

Difference in Class Size When Compiling in 32-bit and 64-bit Mode

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

The size of a class containing any virtual functions varies when compiled in 32-bit mode versus 64-bit mode. The difference in size is caused by the virtual table pointer (a pointer to an internal compiler table) in the class object. (The pointer is created for any class containing one or more virtual functions.)

When compiling the following example in 32-bit mode, the output is 8. In 64-bit mode, the output is 16.

   extern "C" int printf(const char *,...);      class A {      int a;   public:      virtual void foo();  //virtual function foo, part of class A      };   void A::foo() {      return;      }   int main() {      printf("%d\n",sizeof(A));      }
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2007 Hewlett-Packard Development Company, L.P.