Thanks. Sounds reasonable. -- Anders
On Mon, Nov 09, 2009 at 07:25:58AM -0600, Matthew Knepley wrote: > I believe that the cast causes it to offset into the object structure. > Everyone > still > points to the same virtual function table, but the full object structure > consists of > a concatenation of the individual parts for superclasses. This makes it easy > to > do casts. I had to do this when I wrote my own classes for SIDL. > > Matt > > On Mon, Nov 9, 2009 at 7:12 AM, Anders Logg <l...@simula.no> wrote: > > I'm struggling with some problems in the implementation of automatic > update/interpolation during mesh refinement. > > I've narrowed one of the problems down to the following simple > example. Say that a class C inherits from both A and B (which both > have member variables - this is important). Then I would expect an > object c of class C to have the same address/pointer as seen from all > three classes. But what happens is that A and C (if C inherits from A > first) agree on the address, but not B. > > Try the following simple code: > > #include <iostream> > using namespace std; > > class A > { > public: > A() { cout << "A pointer: " << this << endl; } > int avar; > }; > > class B > { > public: > B() { cout << "B pointer: " << this << endl; } > int bvar; > }; > > class C : public A, public B > { > public: > C() { cout << "C pointer: " << this << endl; } > }; > > int main() > { > C c; > > A* a = &c; > B* b = &c; > > cout << "&a = " << a << endl; > cout << "&b = " << b << endl; > cout << "&c = " << &c << endl; > > return 0; > } > > The output when running the program is something like this: > > A pointer: 0x7fff89a97a50 > B pointer: 0x7fff89a97a54 > C pointer: 0x7fff89a97a50 > &a = 0x7fff89a97a50 > &b = 0x7fff89a97a54 > &c = 0x7fff89a97a50 > > Any ideas why this happens? > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkr4FVAACgkQTuwUCDsYZdF2tgCePK5OFioKblaHHfXwRvL6unAe > mB0AniUt6wEKMqcdQvcZbZtjVE7+myw7 > =9DcD > -----END PGP SIGNATURE----- > > _______________________________________________ > DOLFIN-dev mailing list > DOLFIN-dev@fenics.org > http://www.fenics.org/mailman/listinfo/dolfin-dev > > > > > > _______________________________________________ > DOLFIN-dev mailing list > DOLFIN-dev@fenics.org > http://www.fenics.org/mailman/listinfo/dolfin-dev
signature.asc
Description: Digital signature
_______________________________________________ DOLFIN-dev mailing list DOLFIN-dev@fenics.org http://www.fenics.org/mailman/listinfo/dolfin-dev