我无法unsigned char
在z
. myfunc()
我已经尝试了几种方法,但就是想不通。这是我最近的尝试:
int myfunc (int &y, unsigned char (&z)[2]);
int main(int argc, char *argv[]) {
int y = 1;
unsigned char z[2];
int x = myfunc(y, z[2]);
}
int myfunc(int &y, unsigned char (&z)[2]) {
y = 123;
z[0] = foo;
z[1] = bar;
return 456;
}
我收到以下错误:
error: in passing argument 2 of ‘int myfunc(int&, unsigned char (&)[2])’
对于线int myfunc (int &y, unsigned char (&z)[2]);
和:
error: invalid initialization of reference of type ‘unsigned char (&)[2]’ from expression of type ‘unsigned char’
对于线int x = myfunc(y, x);
我应该如何引用它自己的数组(而不是引用数组?)?