0

Possible Duplicate:
howto return a array in a c++ method?

How can an array be returned from a function? I'm going for an effect like this:

int getArray()
{
    return {1, 2, 3, 4, 5};
}

...

int myArray[5] = getArray();

Community
  • 1
  • 1
Maxpm
  • 24,113
  • 33
  • 111
  • 170
  • also: http://stackoverflow.com/questions/845819/how-can-i-return-an-array http://stackoverflow.com/questions/2302279/return-an-array-in-c http://stackoverflow.com/questions/4138660/in-c-how-do-i-return-an-array-of-objects-from-a-function http://stackoverflow.com/questions/4253106/how-can-i-return-an-array-in-c-functions – Cascabel Nov 30 '10 at 15:44

1 Answers1

0

Either dynamic allocation or std::vector. You can't return an array by value.

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151