10.10.1. Using the Array Class

The program of Figs. 10.910.11 demonstrates class Array and its overloaded operators. First we walk through main (Fig. 10.9) and the program’s output, then we consider the class definition (Fig. 10.10) and each of its member-function definitions (Fig. 10.11).

 1   // Fig. 10.9: fig10_09.cpp 2   // Array class test program. 3   #include <iostream> 4   #include <stdexcept> 5   #include "Array.h"  6   using namespace std; 7  8   int main() 9   {10      Array integers1( 7 ); // seven-element Array   11      Array integers2; // 10-element Array by default 12 13      // print integers1 size and contents14      cout << "Size of Array integers1 is " 15         << integers1.getSize()16         << ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.