Is there a way to write the following function code
int* returnFilledArray() {
int* arr = new int[2];
arr[0] = 1;
arr[1] = 2;
return arr;
}
somehow like that? (create and fill the array as one liner).
int* returnFilledArray() {
return new int {1,2};
}
if have tried various combinations, but I allways get some syntax errors, so when if it's possible I would be thankful for a detailed explanation.