> Now if I am using STL, this is currently my attempt at the above:
>
> class Item
> {
> public:
> Item(int v) { value = v; }
> int value;
> };
>
> int main()
> {
> list<Item> items;
> Item item(3);
> items.push_back(item);
>
John, are you sure you want to use STL list, if you were looking for
a vanilla dynamic array try std::vector. It will serve your purpose
very well. STL list is handy when you want to be able to do efficient
(quick) insertion anywhere in the list. Vector is the simplest and in
most cases the most efficient STL construct.
> However, in my C++ version, there are 2 items (as I understand it) -
> the local variable item, which is initialised and passed to
> push_back() to create a copy of it in the list.
No. push_back function takes a reference argument and therefore no
copies are made.
> STL resource then that would also be gratefully received.
http://www.sgi.com/tech/stl/table_of_contents.html
Regards,
Murali.