Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++: TwoDimensional Array: One dimension fixed?

I need to pass a double [][6] to a method. But I don't know how to create that two-dimensional array.

6 is a fixed size (or a "literal constant", if my terminology is right), which the method accepts. I was trying something like this, but without success...

double *data[6] = new double[6][myVariableSize];

So, the method really looks like:

int myMethod(double obj_data[][6]);

Thanks in advance

like image 506
Martijn Courteaux Avatar asked Jul 23 '26 15:07

Martijn Courteaux


1 Answers

I cannot tell from the question which dimension is which, but this might be worth a try:

double (*data)[6] = new double[myVariableSize][6];
like image 63
finnw Avatar answered Jul 26 '26 04:07

finnw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!