You cannot return an array, only a pointer to a dynamically allocated region of memory. Some compilers may allow it, but a standard-compliant one won't.
Yes you can (depends which compiler you use. Microsoft's compiler wouldn't allow it, the last time I checked), but why would you? Returning a private array? That'll break encapsulation (unless you declare the method constant). Returning a global or local array? Just access it directly.
The implementation looks like this: <TYPE>(&<FUNC_ID>(<PARAMETERS>))[<ARR_SIZE>];
No! Don't do that! Returning local variables isn't a good idea. In fact, it's heavily discouraged. Returning an array (not a reference to one, but a local one) is illegal. You'll have to dynamically allocate the array and return a pointer to it, like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int *ReturnArray(constunsignedint);
int main()
{
int *MyArray(ReturnArray(3));
delete [] MyArray;
return(0);
}
int *ReturnArray(constunsignedint Len)
{
return(newint[Len]);
}