// File: tdtest8.cpp // // This file checks that version 8 of // the TwoDimArray class works. // #include #include "twodim8.H" using namespace std ; int main() { unsigned int N = 7 ; TwoDimArray A(N,N) ; // Initialize A with mod 7 times table for (unsigned int i = 0 ; i < N ; i++) { for (unsigned int j = 0 ; j < N ; j++) { A.at(i,j) = (i*j) % N ; } } cout << "\n\nMod " << N << " Multiplication Table:\n\n" ; A.Print() ; N = 9 ; TwoDimArray B(N,N) ; // Initialize B with mod 9 times table for (unsigned int i = 0 ; i < N ; i++) { for (unsigned int j = 0 ; j < N ; j++) { B[i][j] = (i*j) % N ; } } cout << "\n\nMod " << N << " Multiplication Table:\n\n" ; B.Print() ; cout << "\n\nCheck that assignment works!\n" ; cout << "Mod 7 Multiplication Table:\n\n" ; B = A ; A[0][0] = 13 ; B.Print() ; cout << "\n\nCheck that self assignment doesn't foul things up!\n" ; cout << "Mod 7 Multiplication Table:\n\n" ; B = B ; B.Print() ; cout << "\n\nInvoke copy constructor.\n" ; cout << "Mod 7 Multiplication Table:\n\n" ; TwoDimArray C(A) ; A[0][0] = 19 ; C.Print() ; }