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