On 17/11/2010 21:10, Matthias Pleh wrote:
void foo(char[] a) {}
void bar(char[][] b) {}
int main(string[] args)
{
char[4] a;
char[4][4] b;
foo(a); // OK: implicit convertion
bar(b); // Error: cannot implicitly convert
// char[4u][4u] to char[][]
}
what is the reason for the different behaviour?
What's best to pass such multidimensional arrays?
Check the bit about rectangular arrays:
http://digitalmars.com/d/2.0/arrays.html
b is a static array so gets optimised to a dense array which isn't
compatible with bar. well assuming the docs are up to date.
Seems like a poor choice, dense arrays should be explicit.
You can't pass a dense array to a func unless all but the last
dimensions match:
void bar(char[4][] b) {
}
void car(char[10][4][] c) {
}
void main() {
char[4][4] b;
bar(b);
char[10][4][2] c;
car(c);
}
--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk