[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: C++ question (virtual inheritance)
From: Sarang Lakare <sarang () users ! sourceforge ! net>
Date: 2003-02-20 21:15:20
[Download RAW message or body]
Stefan's testcase is exactly like the E():D(this) that is shown below and they
say that "this" is undefined. Here is what Stefan had:
struct B {
B(A *) {}
};
struct C : virtual public A, public B {
C() : B(this) {}
};
So upcast from C* to A* might use the path C* -> B* -> A* but B* is not
defined hence it will seg fault.
Sarang
On Thursday 20 February 2003 03:46 pm, Christian Loose wrote:
> struct A { };
> struct B : virtual A { };
> struct C : B { };
> struct D : virtual A { D(A*); };
> struct X { X(A*); };
> struct E : C, D, X {
> E() : D(this), // undefined: upcast from E* to A*
> // might use path E* -> D* -> A*
> // but D is not constructed
> // D((C*)this), // defined:
> // E* -> C* defined because E() has
> started // and C* -> A* defined because
> // C fully constructed
> X(this) // defined: upon construction of X,
> // C/B/D/A sublattice is fully
> constructed { }
> };
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sarang Lakare
mailto:sarang@users#sourceforge.net
web:http://www.cs.sunysb.edu/~lsarang/linux
!!Join the fight for freedom - Go GNU/Linux!!
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic