D classes inherane. How it works.
Lionello Lunesu
lionello at lunesu.remove.com
Tue Apr 8 18:16:10 PDT 2008
"Gregor Richards" <Richards at codu.org> wrote in message
news:ftga4f$1gbn$1 at digitalmars.com...
> Every destructor in the hierarchy will be called. I don't recall if you
> can do something like ~super(), but the default is exactly as you see:
> bottommost destructor to topmost destructor. flush() in A is being called
> because ~this() in A calls it.
>
> So, you have to make sure that B's destructor doesn't destroy any data
> that is in fact owned by its parent class, A. Why would you, though?
But it appears B's flush is being called, not A's, and B's data is
definately destroyed, because ~B was called before it. Likewise, B's init is
called before B's ctor!
I find it all very worrying. It's a good thing I avoid inheritance like the
plague lately.
L.
More information about the Digitalmars-d
mailing list