I have a function where I would like to return multiple arrays. I know that in c++ does not return an array, but instead returns a pointer to an array. For example:
int* function(double array[])
But what if I need to return multiple arrays (multiple pointers to arrays? say like 2-10). I have thought of one way of doing this. One would be to just pass the arrays to a void function by reference:
void function(int a[], int b[], double c[])
But then we might be passing a lot of arrays as input. I could package all my input arrays into a class, pass the class by reference, but this seems like unnecessary structure. What is the right way to do this? Thanks
But what if I need to return multiple arraysMy first reaction would be "find another way", although if it really is warranted then wrap the arrays in astruct. Either way you should look intostd::arraywhich can be returned by value.ints and one ofdoubles like your code suggests, I don't see a way to do this in a type safe manner without introducing a data type that has three members of the correct type. Maybestd::tuplecould help you?