开发者

Returning an Array from a C++ Function [duplicate]

开发者 https://www.devze.com 2023-01-27 20:38 出处:网络
This question already has answers here: 开发者_开发技巧Closed 12 years ago. Possible Duplicate: howto return a array in a c++ method?
This question already has answers here: 开发者_开发技巧 Closed 12 years ago.

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();


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号