[Dev-C++] STL, iterators and pointers?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Phil S. <fy...@qw...> - 2001-07-06 02:16:36
|
Some questions about the STL containers and iterators. When you insert an object into a multiset (or list, etc.) does it create a copy of the original Object, or does it connect to the original? and I'm not sure how to ask this next one: If you have an iterator for the above multiset, can you get a generic Object* out of it that points to the Object? I tried taking the addressof the dereferenced iterator ( &(*iter) ) but that didn't seem to work out quite right... Why I'm asking: I have two classes, Book and Author that each contain a pointer to the other. I have a multiset of Books, and a multiset of Authors. When I add a new Book, I need to be able to link it to an Author, and vice versa. The Book* I get when I make a new object doesn't correspond to where the iterator is pointing. I guess that I could do this easier if I replaced the reciprical pointers with multiset iterators, but I want to make the Book and Author classes as basic as possible. I'm experimenting with the different STL containers. and I want to not have to adapt the classes for each one. Hoping this makes sense, Phil -- Fy...@qw... |