Quote:Original post by WuTzI think you're confused about how multidimensional arrays work in C++. Your example may compile, and may even appear to work in some cases, but nevertheless it is incorrect.
Here are some examples:
*** Source Snippet Removed ***
Here. Thats all.
the variable "Var" can hold up to 20*20*20*20 floats = 160000 floats.
You can access them like a chessboard.
Here's a little test program you can try:
#include <iostream>int main(){ float* Var = new float[20,20,20,20]; Var[2,7,4,9] = 100; Var[3,7,4,9] = 200; std::cout << Var[2,7,4,9] << std::endl; std::cout << Var[3,7,4,9] << std::endl; delete Var;}
If your method is correct, the output should be:
100200
However, if you run this, I think you'll see the following:200200
I think what's throwing you off here is the behavior of the comma operator in C++, which is a little counterintuitive. (If you're using this method to create multidimensional arrays in your *own* code, you may want to revisit that ;).Also, even if this were to work, it would need to be:
delete [] Var;
Not:delete Var;