Need help with using reserve for vector of objects in C++
I am still learning C++ and trying to use reserve for vector in my project. In fact I am just trying to solve the memory problem and so I am guessing that I can possibly use reserve.
I have vector that has elements of type class. each element is class. I have another vector that is member of that class and the elements of this another vector are pointer to other elements of first vector (pointer to class). Currently I have both of this vectors grows dynamically and don't have any size declared to it.
It doesn't work rightnow. It works for small input but for big input, it has std:bad_alloc. I am not sure what is wrong, but I think, I can reserve big enough size for my outer (first) vector, so that in any case it will not need to reallocate as I am using pointer to the elements and so if it is reallocating, it will invalidate the addresses. I am not sure if I am right here but I have spend so much time but still doesn't work and so I think I can try to reserve either inner or outer vector.
I have my vectors defined like this,
typedef std::vector<ROB_entry*> dependency_list_t;
With above use of reserve, I have an error like this,
error: ISO C++ forbids declaration of ROB with no type
smt.h:77: error: expected ; before . token
If anybody knows what is wrong with my implementation of reserve, Please let me know. Any help will be greatly appreciated.