Workaround Initalization Array

 

Hello,

I am trying and goolging for 2 days now to somehow find a Workaround to initialize an Array with variables. This is what I would like to achieve:

CTest test;

double arr[]={test.val1, test.val2};

I tried different solutions such as using #define and StringToDouble and DoubleToString Solutions but nothing really works.

I am really wondering if there is a good workaround for that.


And why the hell is it not allowed to initialize an Array like this using variables? I do not get it as

arr[0] = test.val1;

works.

 
algotrader01: I tried different solutions s
Try reading the documentation. The values must be constants.
 
Well, I did that. That is why I am asking for a possible workaround
 
algotrader01:

arr[0] = test.val1;

works.

 
That is correct as stated in my original post but I am searching for a workaround to initialise arrays with = { ... } Including variables

Best
 
What part of "must be constants" was unclear? There is no workaround. You've been answered three times.
 
Four times - he asked almost the same in the German forum.
 
algotrader01:

And why the hell is it not allowed to initialize an Array like this using variables?

Because there is always a chance the variables themselves are not initialized.
 
For the moment I give up on this and keep going. However, thanks to anyone for your support! Best wishes!