Hi,
I've a class named Contact and I want to build a data structure of pointers to those objects like a matrix of 127 rows and 20 columns. I've tried to use the std::vector class in this way
std::vector < std::vector<Contact* > > matrix (127, std::vector < Contact* > (20));
then, having declarated the following in the header
std::vector<std::vector<Contact* > > Buckets;
I assign the matrix initialized and declared before to it (this step because basically I don't know how to do it in a more clear and short way):
Buckets = matrix;
but using the push_back function like
Buckets[pot].push_back(cont_temp);
after a while produces an error ("terminate called after throwing an instance of 'std::bad_alloc'") and I don't know how to fix it.
Is there any other better way to instantiate and initialize the matrix? Would you suggest other solutions instead of using a vector of vectors (a boost::multiarray..?) ?
thanks (sorry for the stupid question, I'm a poor student:)
Edit: I've found the error (just an assignment out of bounds). If you have general suggestions for this kind of data structure I'm still here...