Passing around fixed-size arrays in C++?

Viewed 25787

Basically I'd like to do something like that:

int[3] array_func()
{
    return {1,1,1};
}

int main(int argc,char * argv[])
{
    int[3] point=array_func();
}

But that doesn't seem legal in C++. I know I can use vectors, but since I know the size of the array is a constant, it seems like a loss of performance is likely to occur. I'd also like to avoid a new if I can, because allocating stuff on the stack is easier and also likely to improve performance.

What's the solution here?

5 Answers
Related