I can't create a reference to an unsigned char array z within myfunc(). I've tried several ways but just can't figure it out. This is my most recent attempt:
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;
}
I am getting the following errors:
error: in passing argument 2 of ‘int myfunc(int&, unsigned char (&)[2])’
For line int myfunc (int &y, unsigned char (&z)[2]);
And:
error: invalid initialization of reference of type ‘unsigned char (&)[2]’ from expression of type ‘unsigned char’
For line int x = myfunc(y, x);
How should I be referencing the array it self (and not an array of references?) ?
z, notz[2].int myfunc (int &y, std::vector<unsigned char> &z). They provide syntax you'd expect from using other types of parameters.