Class inside a Struct?
Ary Borenszweig via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 30 13:28:41 PST 2015
On 1/30/15 5:28 PM, Ali Çehreli wrote:
> On 01/30/2015 11:59 AM, chardetm wrote:
>
> > struct Container {
> >
> > private RedBlackTree!int _rbtree = new RedBlackTree!int;
>
> I think you are expecting the new expression to be be executed for every
> object individually. It is not the case: That new expression determines
> the initial value of the _rbtree for every single object of type
> Container. As a result, they will all be sharing the same tree.
>
> The best solution is
>
> 1) Remove the new expression:
> 2) Use a static opCall:
Why not use this() ?
More information about the Digitalmars-d-learn
mailing list