How do I define the push_back function for a c++ structure?

Asked

Viewed 601 times

0

How do I use the function push_back in a structure?

I have the arch structure:

struct Arco {

    int i, j;
    Arco () {};
    Arco (const Arco& obj): i(obj.i), j(obj.j) {};
    Arco(int _i, int _j) : i(_i), j(_j) {}    

};

And then, I have a vector of arcing vectors:

vector < vector < Arco > > Df;

Df = vector < vector < Arco > >(nn, vector < Arco > ( ) );

I wish I could fill in the Df as follows:

Df[i][j].push_back(Arco(u,v));

How must I allow this command?

1 answer

1

You have only one vector of vectors (2D).

Soon the correct use would be this:

Df[i].push_back(Arco(u,v));

If your need is to use Df[i][j].push_back(Arco(u,v)); Then a vector vector of vector (3D)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.