Struct Base1 {
Int val1;
};
Struct Base2 {
Int val2.
};
Struct Derived: Base1, Base2 {
//...
};
Int main ()
{
STD: : cout & lt; <(int) (& amp; (0) (Base1 *) - & gt; Val1) & lt;
Printf (" & amp; Base2: : val2=% p \ n ", & amp; Base2: : val2);
Printf (" & amp; Derived: : val1=% p \ n ", & amp; Derived: : val1);
Printf (" & amp; Derived: : val2=% p \ n ", & amp; Derived: : val2);
return 0;
}
STD: : cout & lt; <(int) (& amp; (0) (Derived *) - & gt; Val2) & lt;
Printf (" & amp; Derived: : val2=% p \ n ", & amp; Derived: : val2);
Is not for migration, or am I wrong?
CodePudding user response:
Int Base1: : * p1=& amp; Derived: : val1;
Int Base2: : * p2=& amp; Derived: : val2;
Derived d;
D. * p1=1;
D. * p2=2;
The debug, p1 and p2 is what value?
CodePudding user response:
The problem of priority levelCout<& (((Base1 *) 0) - & gt; Val);//structure address 0 (0 address is null, is expected to be an error)