Workaround Initalization Array

To add comments, please log in or register
algotrader01
114
algotrader01  

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.

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

arr[0] = test.val1;

works.

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

Best
whroeder1
17944
whroeder1  
What part of "must be constants" was unclear? There is no workaround. You've been answered three times.
Carl Schreiber
Moderator
7071
Carl Schreiber  
Four times - he asked almost the same in the German forum.
kypa
976
kypa  
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.
algotrader01
114
algotrader01  
For the moment I give up on this and keep going. However, thanks to anyone for your support! Best wishes!
To add comments, please log in or register