Re: Member offsets in multiple inheritance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26 May 2011 12:27, pieniek <edek.pienkowski@xxxxxxxxx> wrote:
> Hello,
>
> I have always though, that given a pointer to an object, members are at
> (this) + (member-offset). But this cannot be true for multiple inheritance,
> no?
>
> Example:
>
> struct A {
>   int x,y;
> }
>
> struct B {
>   int a, b, c;
> }
>
> struct C : public A, public B {}
>
> int func (B* b, B* actuallyCinstance) {
>    return b->b + actuallyCinstance->b;
> }

actuallyCinstance points to the B sub-object of a C instance, so the
offset to B::b is the same for both dereferences.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux