/* * File: arraytest.cpp * Author: Robert I. Pitts * Last Modified: Fall 2000 * Topic: Templates * ----------------------------------------------------- * * OVERVIEW: * ========= * This program tests a "resizable array" class. * */ #include #include #include "array.h" int main() { int size; cout << "Array of integers:" << endl; // Create an integer array. Array iarray; cout << "Enter the size for array (greater than 0): "; cin >> size; cout << endl; // Make it big enough. iarray.resize(size); // Add some values. for (int i = 0; i < iarray.size(); i++) { cout << "Enter value #" << i << ": "; cin >> iarray[i]; } cout << endl; // Make it a new size. cout << "Enter new size for array (greater than 0): "; cin >> size; iarray.resize(size); cout << endl; // Print values. for (int i = 0; i < iarray.size(); i++) { cout << "Value #" << i << " = " << iarray[i] << endl; } cout << endl; cout << "Array of strings:" << endl; // Create a string array. Array sarray; cout << "Enter the size for array (greater than 0): "; cin >> size; cout << endl; // Make it big enough. sarray.resize(size); // Add some values. for (int i = 0; i < sarray.size(); i++) { cout << "Enter value #" << i << ": "; cin >> sarray[i]; } cout << endl; // Make it a new size. cout << "Enter new size for array (greater than 0): "; cin >> size; sarray.resize(size); cout << endl; // Print values. for (int i = 0; i < sarray.size(); i++) { cout << "Value #" << i << " = " << sarray[i] << endl; } }