Closed omerbrandis closed 1 year ago
Try this:
struct MyStruct
{
decimal<2> myVariable{ 0 };
};
it works , :-)
thank you Kvaz1r,
can you please tell me a bit more about what/why this is ?
thanks, Omer.
@omerbrandis The "0" is just an example or a real value? It looks like you are trying to investigate rules of initialization which can be very complicated - if you do not provide your own constructor. Solution from @Kvaz1r probably works but I would suggest to add a default constructor with initialization of myVariable.
// untested
struct MyStruct
{
decimal<2> myVariable;
MyStruct(): myVariable(0) { }
}
See rules (I have already a headache after reading it):
thanks !
Hello Piotr
First I must thank you for creation, its really a must in the cpp space.
I'm using 1.18, and am unable to compile the following struct MyStruct { decimal<2> myVariable(0); }
also can't struct MyStruct { decimal<2> myVariable = 0; } error : could not convert ‘0’ from ‘int’ to ‘dec::decimal<2>’ ^
I can set a value in the constructor mil. this is a decent workaround , but less convenient for me at this time.
please advise, Omer.