jeudi 21 juillet 2022

Vector of pointers saving a pointer to a vector of ints

just wondering if you can point to a pointer that points to a vector of ints. And save the pointer that points to a vector of ints. Here's the code I'm trying to pull off. Probably dosen't make sense but I'm trying to make it work for a while now, bare with me. But I want to pull this way somehow.

int n, q;
cin >> n >> q;
vector <int*> ar;

for (int i=0;i<n;i++){
    
    int k;
    cin >> k;

    vector< int >  *vec;

    for(int j = 0;j<k;j++){
        (*(vec+j)).push_back(cin.get());

    }
    ar.push_back(&(vec));


}

Thanks for the possible help. Haven't seen this asked in here, just things a bit different than this.

Aucun commentaire:

Enregistrer un commentaire