// Ch. 15 Demo Program #2
// Mr. Minich
// Purpose - to illustrate the use of matrix objects from the apmatrix class
#include <iostream.h>
#include "M:\C++ Programming\AP classes\apmatrix.h"
int main()
{
apmatrix <char> charMatrix(3,3,' '); // 3 x 3 matrix of blank spaces
apmatrix <char> originalMatrix; // initially a matrix w/ no elements
int row; // row of matrix
int col; // column of matrix
char character; // user input, character for matrix
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
cout << "Please enter a character for matrix position ("
<< row << ", " << col << "): ";
cin >> character;
charMatrix[row][col] = character;
}
}
originalMatrix = charMatrix;
cout << "The charMatrix has " << charMatrix.numrows() << " rows and "
<< charMatrix.numcols() << " columns.\n";
charMatrix.resize(2,2);
cout << "charMatrix now has " << charMatrix.numrows() << " rows and "
<< charMatrix.numcols() << " columns.\n";
cout << "\nThe original matrix looked like:\n";
for(row = 0; row < originalMatrix.numrows(); row++)
{
for(col = 0; col < originalMatrix.numcols(); col++)
{
cout << originalMatrix [row][col] << ' ';
}
cout << endl;
}
// ************************ resized matrix **************
cout << "\nThe resized matrix looks like:\n";
for(row = 0; row < charMatrix.numrows(); row++)
{
for(col = 0; col < charMatrix.numcols(); col++)
{
cout << charMatrix [row][col] << ' ';
}
cout << endl << endl;
}
return 0;
}// end of main