Delete an object pointed by a pointer returned from another function

Make your F() function like

#include<iostream>
using namespace std;
vector<int> F() {
    vector<int> x;
    x.resize(4);
    x[1]=1; x[2]=2; x[3]=3;
    return x;
}

No need for F1().

Leave a Comment