Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 03, 2004 Object array crash | ||||
---|---|---|---|---|
| ||||
This crashes (between "2" and "3") unless the destructor is enabled. The code it was derived from worked under SC7.5. Apologies if I've misunderstood the use of object arrays! regards, Rick --- #include <stdio.h> // // Compile: sc test2 // // This program crashes. If USE_DESTRUCTOR is enabled, its OK // //#define USE_DESTRUCTOR 1 class Test2 { int foo; public: Test2(); #ifdef USE_DESTRUCTOR ~Test2() {} #endif }; Test2::Test2() { foo = 123; }; main() { printf("1\n"); Test2 * ptr = new Test2[500]; printf("2\n"); delete [] ptr; printf("3\n"); return 0; }; |
April 07, 2004 Object array crash - any comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Riccardo Macri | Any comments on why my previous posting (3rd of March) crashes? Its repeated below. thanks Riccardo In article <c24rsr$12fo$1@digitaldaemon.com>, Riccardo Macri says... > >This crashes (between "2" and "3") unless the destructor is enabled. The code it was derived from worked under SC7.5. > >Apologies if I've misunderstood the use of object arrays! > >regards, >Rick > >--- > >#include <stdio.h> > >// >// Compile: sc test2 >// >// This program crashes. If USE_DESTRUCTOR is enabled, its OK >// > >//#define USE_DESTRUCTOR 1 > >class Test2 >{ >int foo; > >public: > >Test2(); > >#ifdef USE_DESTRUCTOR >~Test2() {} >#endif >}; > >Test2::Test2() >{ >foo = 123; >}; > >main() >{ >printf("1\n"); >Test2 * ptr = new Test2[500]; >printf("2\n"); >delete [] ptr; >printf("3\n"); > >return 0; >}; > > |
April 07, 2004 Re: Object array crash - any comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Riccardo Macri | No, not yet, sorry. "Riccardo Macri" <Riccardo_member@pathlink.com> wrote in message news:c51m64$10hr$1@digitaldaemon.com... > Any comments on why my previous posting (3rd of March) crashes? > > Its repeated below. > > thanks > Riccardo |
Copyright © 1999-2021 by the D Language Foundation