Constructors not working

Ali Çehreli acehreli at yahoo.com
Fri Sep 2 18:44:20 UTC 2022


On 9/2/22 11:35, Svyat wrote:

 >          Time time = 360;

It seems to be more idiomatic to write it like this:

   auto time = Time(360);

Or const, immutable, etc.

   const time = Time(360); // Now un-assignable

But you would get the same compilation error. So, one way to work with 
it is to use default constructor arguments:

   this(int h, int m = 0, int s = 0)

Then it would work with just 360.

 > .\testfortime.d(6):        too few arguments, expected `3`, got `1`"

At least that one is helpful. There are much more cryptic error messages 
out there. :)

Ali



More information about the Digitalmars-d-learn mailing list