Figure 3: Main program for IArray class
// Main program for IArray class
#ifndef IARRAY2_H
#include "iarray2.h"
#endif
main()
{
// Use default constructor
IArray a1;
// Use secondary constructor to init
// an array from an int*
const int d[] = { 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11 };
IArray a2 (d, 12);
// Create a new array using a2
// to test the copy constructor
IArray a3 (a2);
// Use the subscript operator to
// change a2
for (int i = 0; i < a2.Size(); i++)
a2[i] *= 10;
// Assign a2 to a1
a1 = a2;
// Print out the arrays
cout << "A1 is " << endl << a1 << endl;
cout << "A2 is " << endl << a2 << endl;
cout << "A3 is " << endl << a3 << endl;
}
© Copyright 2000-2004 by ACM, Inc.
Page hits since December 20, 1999: