P
Patricia
First, I know the following code is bad, but it's from a library I have
to use, and I can't change it.
class A {
// some primitive members
};
class B {
// some primitive members
};
class C : public A, B {
// no members
};
main() {
// I know sizeof(A) = 16, sizeof(B) = 60
C * pc = (C*) new char[sizeof(A) + sizeof(B)];
B * pb = (B*) pc;
char * p1 = (char *) pc;
char * p2 = (char *) pb;
cout << "offset : " << (p2 - p1) << endl;
}
What surprised me is that the offset is 20 instead of 16. Do you know
the possible reason?
Regards.
to use, and I can't change it.
class A {
// some primitive members
};
class B {
// some primitive members
};
class C : public A, B {
// no members
};
main() {
// I know sizeof(A) = 16, sizeof(B) = 60
C * pc = (C*) new char[sizeof(A) + sizeof(B)];
B * pb = (B*) pc;
char * p1 = (char *) pc;
char * p2 = (char *) pb;
cout << "offset : " << (p2 - p1) << endl;
}
What surprised me is that the offset is 20 instead of 16. Do you know
the possible reason?
Regards.