Im struggling to understand Trailing return types. Ive bee searching for simple example to understand it but cant find anything
Basically..If i have a function declaration like this func(int i) -> int (*)[10];
How am i supposed to define it? Is it like this?
1 2 3 4
auto func(int i) -> int(*)[10]{
return ?// what is it that im supposed to return?
}
but the problem is I dont know what I am supposed to return? Returning i is invalid.
Again as from my previous questions this is all about the book that i am reading to learn c++ and sometimes doesnt give much information about a certain like this trailing return type that leaves me scratching my head.
This btw about a function that return an array which is illegal in c++ but can attain the result in different way for example
1 2 3
typedefint arrT[10];
using arrtT = int[10];
arrT* func(int i);
again the author of that book explains what should happen but didnt use it to a usefull example.
It is not local. It is static. It will be created when function first executed and will exist until program finishes. It will not be recreated between function calls and it is a possibility for function to save its state between calls.