// Oldham, Jeffrey D. // 2000Mar17 // CS1321 // Test Dynamic Array Implementations // Test set(). #include #include // has EXIT_SUCCESS #include // helps detect memory leaks #include "dynamicArray.h" int main(int argc, char *argv[]) { mtrace(); // turn on memory leak detection if (argc != 2) { cerr << argv[0] << ": number-of-pushes\n"; throw "missing command-line argument"; } dynamicArray::length_pos nuPushes = strtoul(argv[1], static_cast(0), 0); // Do not check for errors. Bad! dynamicArray d; for (dynamicArray::length_pos i = 0; i < nuPushes; ++i) d.push_back(2*i+1); // Perform the set()s. for (dynamicArray::length_pos i = 0; i < nuPushes; i += 2) d.set(i,-(2*i+1)); d.set(nuPushes-1, -(2*(nuPushes-1)+1)); // Print the values. d.push_back(1234567890); for (dynamicArray::length_pos i = 0; i < nuPushes+1; ++i) cout << i << ":\t" << d.get(i) << endl; return EXIT_SUCCESS; }