/////////////////////////////////////////////////////////////// // MT3Q6.h - Matrix // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2012 // /////////////////////////////////////////////////////////////// #include "MT3Q6b.h" int main() { std::cout << "\n MT3Q6b - Alternate Matrix"; std::cout << "\n ===========================\n"; try { std::cout << "\n create and define some elements"; std::cout << "\n ---------------------------------"; Matrix m; m(0,1) = 1; m(1,2) = 2; m(2,3) = 3; //////////////////// // these work too //m[0][1] = 1; //m[1][2] = 2; //m[2][3] = 3; Display(m); std::cout << "\n copy"; std::cout << "\n ------"; Matrix mcopy = m; Display(mcopy); std::cout << "\n revise"; std::cout << "\n --------"; mcopy[1][2] = -2; mcopy[2][0] = 2; Display(mcopy); std::cout << "\n assign"; std::cout << "\n --------"; m = mcopy; Display(m); std::cout << "\n indexing out of range"; std::cout << "\n -----------------------"; int elem = m[4][0]; // row index error will be handled //int elem = m[0][4]; // col index error will not std::cout << "\n"; } catch(std::exception& ex) { std::cout << "\n " << ex.what() << "\n\n"; return 1; } return 0; }