By doing this:
vector<vector<t_PCB> > multilevel[4];
You declare an array of four zero-sized vectors
, each of which can contain objects of type vector<t_PCB>
. What you probably wanted to do is rather:
vector<vector<t_PCB> > multilevel(4);
// ^^^
This will instantiate a vector of four default-initialized objects of type vector<t_PCB>
. Then, you can just do:
multilevel[size].push_back(p);
Notice, though, that vector indices (like array indices) are zero-based, so size
must be less than the size of the vector.
In the above expression, the sub-expression multilevel[size]
returns a reference to the size
-th vector inside multilevel
, and on that vector you are then invoking the member function push_back(p)
, which appends element p
to it.