digitalmars.D - Exceptions part 3: Auto objects
- Sean Kelly <sean f4.ca> Apr 13 2005
# /*
# 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
Apr 13 2005








Sean Kelly <sean f4.ca>