this is my simple code to return vector by reference:
#include <bits/stdc++.h>
using namespace std;
vector<int>& VECTORTEST(){
vector<int> v;
v.push_back(10);
v.push_back(20);
return v;
}
int main()
{
vector<int> x = VECTORTEST();
return 0;
}
But I am getting segmentation fault when run this code. Any idea?