Quote:
This has no overhead at all in C or C++. It may in Java or other languages, but in C the entire multidimensional array is stored linearly in one block of memory with each row immediately after the previous row. He said you could store it as a single dimensional array and refer to it with [column +(row*num_columns)] and you can if you want, but that is exactly what the program does when you put [row][column]. You can even declare it as two dimension and type cast it to one dimension and refer to it interchangably. So the only over head is a pointer look up and an addition and multiplication, if you worry over that then you should see a shrink.
|
exactly.
Quote:
I don't think you can declare a static variable inside a method, and even if you can it will do absolutely nothing because variables declared in a method cease to exist once the method stops running. Of course if you have two instances of the method running at the same time it may make them share the variables, but I have no idea.
|
[Quote] Normally, variables defined local to a function disappear at the end of the function scope. When you call the function again, storage for the variables is created anew and the values are re-initialized. If you want a value to be extant throughout the life of a program, you can define a function