How about this:

struct A {
        int     z;
};

struct B {
        struct A a;
        int     y;
};

struct C {
        struct B b;
        int     x;
};

struct C        abc;

main  ()
{
        printf ("&abc \t== 0x%08xd\n", &abc);
        printf ("&abc.b\t== 0x%08xd\n", &abc.b);
        printf ("&abc.b.a\t== 0x%08xd\n", &abc.b.a);
        printf ("&abc.b.a.z\t== 0x%08xd\n", &abc.b.a.z);
}


gcc t.c -o t
./t
&abc    == 0x080495bcd
&abc.b  == 0x080495bcd
&abc.b.a        == 0x080495bcd
&abc.b.a.z      == 0x080495bcd

In other words, it is perfectly reasonable for objects of different
types to have the same address (note the above was C, not C++).

--pete



Reply via email to