private final class destructors

bearophile bearophileHUGS at lycos.com
Thu Aug 19 06:40:39 PDT 2010


According to TDPL the whole object destructor chain is called up to the top of the hyerarchy.
This D2 program compiles and runs with DMD 2.048 with no errors:


import std.c.stdio: puts;
class Base {
     private final ~this() { puts("Base.~this"); }
}
class Derived : Base {
    private final ~this() { puts("Derived.~this"); }
}
void main() {
    new Derived();
}


Output:

Derived.~this
Base.~this


Are the 'private final' attributes used here correct?
See also:  http://d.puremagic.com/issues/show_bug.cgi?id=3934

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list