/* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software is provided "as is" without express or implied * warranty, and with no claim as to its suitability for any purpose. */ #include #include #include #include #include "countptr.hpp" using namespace std; void printCountedPtr (CountedPtr elem) { cout << *elem << ' '; } int main() { // array of integers (to share in different containers) static int values[] = { 3, 5, 9, 1, 6, 4 }; // two different collections typedef CountedPtr IntPtr; deque coll1; list coll2; /* insert shared objects into the collections * - same order in coll1 * - reverse order in coll2 */ for (int i=0; i