1 // Compile with "cl /c /Zi /GR- ClassLayoutTest.cpp" 2 // Link with "link ClassLayoutTest.obj /debug /nodefaultlib /entry:main" 3 4 namespace MembersTest { 5 class A { 6 public: 7 typedef int NestedTypedef; 8 enum NestedEnum { 9 NestedEnumValue1 10 }; 11 MemberFunc()12 void MemberFunc() {} 13 14 private: 15 int IntMemberVar; 16 double DoubleMemberVar; 17 }; 18 } 19 20 namespace GlobalsTest { 21 int IntVar; 22 double DoubleVar; 23 24 typedef int Typedef; 25 enum Enum { 26 Val1 27 } EnumVar; 28 Typedef TypedefVar; 29 } 30 31 namespace BaseClassTest { 32 class A {}; 33 class B : public virtual A {}; 34 class C : public virtual A {}; 35 class D : protected B, private C {}; 36 } 37 38 namespace UdtKindTest { 39 struct A {}; 40 class B {}; 41 union C {}; 42 } 43 44 namespace BitFieldTest { 45 struct A { 46 int Bits1 : 1; 47 int Bits2 : 2; 48 int Bits3 : 3; 49 int Bits4 : 4; 50 int Bits22 : 22; 51 int Offset0x04; 52 }; 53 }; 54 main(int argc,char ** argv)55int main(int argc, char **argv) { 56 MembersTest::A v1; 57 v1.MemberFunc(); 58 BaseClassTest::D v2; 59 UdtKindTest::A v3; 60 UdtKindTest::B v4; 61 UdtKindTest::C v5; 62 BitFieldTest::A v7; 63 return 0; 64 } 65