**fig3_8.txt** /* 1*/ // An example which instantiates two integer list classes. /* 2*/ // The main routine does some insertions, removals, and copies, /* 3*/ // Printing the list every now and then. /* 4*/ // Print_List uses only the public functions. /* 5*/ #include /* 6*/ void /* 7*/ Print_List( List & L ) /* 8*/ { /* 9*/ if( L.Is_Empty( ) ) /*10*/ cout << "Empty list." << endl; /*11*/ else /*12*/ for( L.First( ); !L; ++L ) /*13*/ cout << L( ) << endl; /*14*/ } /* 1*/ main( ) /* 2*/ { /* 3*/ List L1, L2; /* 4*/ cout << "( This should be empty )" << endl; /* 5*/ Print_List( L1 ); /* 6*/ for( int i = 1; i <= 5; i++ ) /* 7*/ L1.Insert_As_First_Element( i ); /* 8*/ cout << "( This should be 5 4 3 2 1 )" << endl; /* 9*/ Print_List( L1 ); /*10*/ for( i = 4; i <= 6; i++ ) /*11*/ if( L1.Find( i ) ) /*12*/ cout << "Found " << L1( ) << endl; /*13*/ else /*14*/ cout << i << " not found." << endl; /*15*/ L2 = L1; /*16*/ cout << "( This should be 5 4 3 2 1 )" << endl; /*17*/ Print_List( L2 ); /*18*/ L2.Remove( 3 ); /*19*/ cout << "( This should be 5 4 2 1 )" << endl; /*20*/ Print_List( L2 ); /*21*/ cout << "( But list L1 should be unchanged 5 4 3 2 1 )" << endl; /*22*/ Print_List( L1 ); /*23*/ return 0; /*24*/ }