// File: testarray.cpp // Driver for template array ADT // Daniel S Spiegel #include #include #include "array.h" #include "SortSearch.h" using namespace std; void main() {array ints; for (int i=0;i<10;i++) ints[i]=i*7-3; cout << ints << endl; ints+=56; cout << ints << endl; array s1; // array s2; Drawback: Can't do any operations with this array s2; ostringstream os; for ( int j = 1; j < 10; j++ ) { os << (char)(j+64); s1[j]=os.str(); } cout << s1 << endl; s1+="CS 242 is great!"; cout << s1 << endl; s2=s1; cout << s2 << endl; s2[3]="l-value"; cout << s2 << endl; array s3(s1); cout << s3 << endl; int intList[10]={109,55,43,41,55,46,57,68,19,10}; array list(intList); // intList has 10 elts; does it work? What happens? cout << "list, built from intList:" << list << endl; array list2(intList); cout << "list2, built from intList:" << list2 << endl; selSort(intList,10); array list3(intList); cout << "list3, built from intList after sort:" << list3 << endl; // Next line works, but has funny results. Why?; array list4(intList); cout << "list4, built from intList after sort:" << list4 << endl; }