C++ STL Containers
Posted: Fri Oct 03, 2003 9:46 am
Hi!
I'm playing around with the STL library and trying to create a vector container of classes:
Now, i'm trying to create a GUI listbox, populating it with data from the vector. For each item in the listbox, I want to have a pointer to the specific class in the vector. That way, if an event occurs for that item in the listbox, i can get more information from the class.
Now, as I understand it, an iterator acts as a pointer to data within container classes but they are only correct up to the point you start adding or removing data.. this isn't good for me since i want to create a pointer to data and delete stuff from the list as well
So how can I get a pointer to the data in the container that will still work after I add/delete items from the container? Or will i just have to create a vector of pointers instead?
- Nick
I'm playing around with the STL library and trying to create a vector container of classes:
Code: Select all
class MyClass
{
....
};
class MyClassVector: public vector<MyClass>
{
};
Now, as I understand it, an iterator acts as a pointer to data within container classes but they are only correct up to the point you start adding or removing data.. this isn't good for me since i want to create a pointer to data and delete stuff from the list as well
So how can I get a pointer to the data in the container that will still work after I add/delete items from the container? Or will i just have to create a vector of pointers instead?
- Nick