#include #include #include using namespace std; #include "dynamic_array.h" int main(){ /* Test routine will go here */ dynamic_array dbarray; dbarray += 3.4; dbarray += 8.6; dbarray += 7.2; dbarray += 9.3; /* For demo of copy constructor */ { dynamic_array backup = dbarray; cout << "backup: " << backup[0] << endl; backup[1] = 10000; } dbarray.reserve(100); for(double newval = 20.1; newval < 49; newval += 1.05) dbarray += newval; dbarray.trim(); for(int i = 0; i < dbarray.items(); i++) cout << dbarray[i] << endl; for(int i = 0; i < 30; i++) dbarray.pop_back(); dbarray.trim(); cout << "After removing 30 items and trimming:\n"; for(int i = 0; i < dbarray.items(); i++) cout << dbarray[i] << endl; dynamic_array other_dbarray; other_dbarray += 100.1; other_dbarray += 100.2; other_dbarray += 100.3; cout << "Combining both arrays\n"; dynamic_array both = dbarray + other_dbarray; for(int i = 0; i < both.items(); i++) cout << both[i] << endl; /* What if we need to call a destructor? */ dynamic_array sarray; sarray += "There was once a shark that liked to eat grapes."; sarray += "It would follow boats, swimmers, and surfers seeking grapes."; sarray += "Nobody could catch it with bait, because they used the wrong type."; for(int i = 0; i < sarray.items(); i++) cout << sarray[i] << endl; return 0; }