Default value for member class
    JN 
    666total at wp.pl
       
    Mon Feb 10 18:18:16 UTC 2020
    
    
  
class IntValue
{
     int x = 5;
}
class Foo
{
     IntValue val = new IntValue();
}
void main()
{
     Foo f1 = new Foo();
     Foo f2 = new Foo();
     assert(f1.val == f2.val);
}
Is this expected? Or should each Foo have their own IntValue 
object? They're equal right now, changing one changes the other. 
When exactly is the "new IntValue" happening? On program init, or 
when calling new Foo() for the first time?
    
    
More information about the Digitalmars-d-learn
mailing list