Immutable objects and constructor ?

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 20 07:44:31 PDT 2016


On Friday, 20 May 2016 at 14:40:23 UTC, Kagamin wrote:
> On Friday, 20 May 2016 at 14:06:54 UTC, chmike wrote:
>> But when I try to instantiate the class I get an dramatic 
>> compilation error:
>>
>> "none of the overloads of '__ctor' are callable using a 
>> mutable object, candidates are: "
>
> auto a=new immutable Info(1,"1");
>
>> How should I do if I would like to use the lazy pattern for 
>> initializing some member variables of the instance ?
>
> Use mutable class.

Thank you very much for the fast and very helpful reply. I'll try 
that.






More information about the Digitalmars-d-learn mailing list