I read How to return a local array from a C/C++ function? topic and confused about the last code block of it:
#include <iostream>
using namespace std;
struct arrWrap {
int arr[100];
~arrWrap()
{
}
};
struct arrWrap fun()
{
struct arrWrap x;
x.arr[0] = 10;
x.arr[1] = 20;
return x;
}
int main()
{
struct arrWrap x = fun();
cout << x.arr[0] << " " << x.arr[1];
return 0;
}
can somebody analyze this for me what is the idea?