April 14, 2005 Exceptions part 3: Auto objects | ||||
---|---|---|---|---|
| ||||
# /* # This example demonstrates that auto objects that are part # of an inheritance heirarchy are not destroyed on scope exit. # */ # auto class AutoTest # { # # } # # auto class AutoTest1 : AutoTest # { # this() # { # printf( "AutoTest1 ctor\n" ); # } # # ~this() # { # printf( "AutoTest1 dtor\n" ); # } # } # # # void main() # { # try # { # auto AutoTest a = new AutoTest1(); # } # catch( Exception e ) # { # printf( "fail: %.*s\n", e.toString() ); # } # fullCollect(); # printf( "done\n" ); # } Output: AutoTest1 ctor done AutoTest1 dtor |
Copyright © 1999-2021 by the D Language Foundation