B
bergmush
#include <iostream>
using namespace std;
class A {
};
class B {
};
class C : public A, public B {
};
int main() {
A *pA = 0;
B *pB = 0;
C c;
pA = &c;
pB = &c;
cout << sizeof(c) << endl;
cout << pA << " : " << pB << " : " << &c << endl;
return 0;
}
OUTPUT:
1
0012FF74 : 0012FF75 : 0012FF74
Why does sizeof return 1 but when looking at the pointers we get
addresses of two different bytes in memory?
using namespace std;
class A {
};
class B {
};
class C : public A, public B {
};
int main() {
A *pA = 0;
B *pB = 0;
C c;
pA = &c;
pB = &c;
cout << sizeof(c) << endl;
cout << pA << " : " << pB << " : " << &c << endl;
return 0;
}
OUTPUT:
1
0012FF74 : 0012FF75 : 0012FF74
Why does sizeof return 1 but when looking at the pointers we get
addresses of two different bytes in memory?