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? -- Anders
signature.asc
Description: Digital signature
_______________________________________________ DOLFIN-dev mailing list DOLFIN-dev@fenics.org http://www.fenics.org/mailman/listinfo/dolfin-dev