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

0

How can I use the push_back function in a structure?

I have the Arc 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 so I have a vector of arcs vectors:

vector < vector < Arco > > Df;

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

I would like to be able to fill Df like this:

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

How do I enable this command?

    
asked by anonymous 23.08.2015 / 00:09

1 answer

1

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

So 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 you will need a vector vector of vector (3D)

    
23.08.2015 / 05:01