0

I tried this:

int ([]foo)();
int[] foo();
int (foo[])();

But it didn't declare what I expected. Is it possible?

I don't mean declaring a function returning a pointer. I need to return exactly an array.

4
  • What is the difference between a pointer and an array, for you ? Commented Jun 9, 2015 at 11:00
  • You can't return an array, but you can return a reference to an array, or a std::array. What do you actually need this for? Commented Jun 9, 2015 at 11:00
  • @Ninetainedo Well, it's the different type. It's not only for me, it's for all. The thing that there's the array-to-pointer conversion and arrays're adjusted to pointers when they're odr-used Commented Jun 9, 2015 at 12:40
  • I am really curious about your requirements because the array will be implicitly turned into a pointer. So what will it change, concretly ? Commented Jun 9, 2015 at 13:11

1 Answer 1

0

What you want to return from your function is actually a pointer to the first element in the array:

int* arr(int arr[]);

for more information look at this function.

Sign up to request clarification or add additional context in comments.

2 Comments

You should be more explicit because of the I don't mean declareing a function returning a pointer. part of the question.
added a link to the answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.