J
Jeff
Ive used straight vectors before, but never a vector of vectors
I realize this is a simple problem but for some reason I cant figure it
out.
Im getting a SEGV on the following line of code:
(I only put in relevant parts). x is defined as int *
and passed into the method as such.
typedef vector<vector< int * > > Item;
Item _item;
_item[0].push_back(x); <------SEGV line
However, if I use a single vector, it works fine:
typedef vector<int *> Item;
Item _item;
_item.push_back(x); <----- Ok
I realize this is probably a memory allocation issue on the vector of
vectors,
but why not on the single vector?
Secondly, how do I pre-allocate on the first example?
thanks for your help.
I realize this is a simple problem but for some reason I cant figure it
out.
Im getting a SEGV on the following line of code:
(I only put in relevant parts). x is defined as int *
and passed into the method as such.
typedef vector<vector< int * > > Item;
Item _item;
_item[0].push_back(x); <------SEGV line
However, if I use a single vector, it works fine:
typedef vector<int *> Item;
Item _item;
_item.push_back(x); <----- Ok
I realize this is probably a memory allocation issue on the vector of
vectors,
but why not on the single vector?
Secondly, how do I pre-allocate on the first example?
thanks for your help.