Re: Creating 1000 instances

2021-02-19 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 19 February 2021 at 10:02:05 UTC, Siemargl wrote: On Friday, 19 February 2021 at 08:29:36 UTC, Ferhat Kurtulmuş wrote: Since classes are reference types all instances of files will be the same reference of "new File()", which you probably don't want. Is any differences between x

Re: Creating 1000 instances

2021-02-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 19 February 2021 at 10:02:05 UTC, Siemargl wrote: On Friday, 19 February 2021 at 08:29:36 UTC, Ferhat Kurtulmuş wrote: Since classes are reference types all instances of files will be the same reference of "new File()", which you probably don't want. Is any differences between x

Re: Creating 1000 instances

2021-02-19 Thread Siemargl via Digitalmars-d-learn
On Friday, 19 February 2021 at 08:29:36 UTC, Ferhat Kurtulmuş wrote: Since classes are reference types all instances of files will be the same reference of "new File()", which you probably don't want. Is any differences between x and y definitions? MyClass [] x, y; x = new MyClass[7]; y=

Re: Creating 1000 instances

2021-02-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 19 February 2021 at 08:29:36 UTC, Ferhat Kurtulmuş wrote: On Friday, 19 February 2021 at 08:04:19 UTC, Виталий Фадеев wrote: [...] files = new File[]( 1000 ); files[] = new File(); // add this Since classes are reference types all instances of files will be the same reference of

Re: Creating 1000 instances

2021-02-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 19 February 2021 at 08:41:06 UTC, Ferhat Kurtulmuş wrote: On Friday, 19 February 2021 at 08:29:36 UTC, Ferhat Kurtulmuş wrote: On Friday, 19 February 2021 at 08:04:19 UTC, Виталий Фадеев wrote: [...] files = new File[]( 1000 ); files[] = new File(); // add this Since classes are

Re: Creating 1000 instances

2021-02-19 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 19 February 2021 at 08:04:19 UTC, Виталий Фадеев wrote: We have: class File { // WIN32_FIND_DATAW data; } void fastReadDir() { File[] files; // reserve space, allocating instances files = new File[]( 1000 ); // <--- trouble here ?

Creating 1000 instances

2021-02-19 Thread Виталий Фадеев via Digitalmars-d-learn
We have: class File { // WIN32_FIND_DATAW data; } void fastReadDir() { File[] files; // reserve space, allocating instances files = new File[]( 1000 ); // <--- trouble here ? // filling instances auto file = files.ptr;