10.10.1. Using the Array Class
The program of Figs. 10.9–10.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 contents 14 cout << "Size of Array integers1 is " 15 << integers1.getSize() ...
Get C++ How to Program, Ninth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.