#include <iostream>
using namespace std;
// declaring class matrix
class matrix
{ // 10 by 10 matrix is declared in private section
int abc[10][10];
public:
// constructor to create r by c array
matrix (int r, int c)
{
int abc[r][c];
}
// member function to get value from array at [r][c]
int getel (int r, int c)
{
return abc[r][c];
}
// member function to insert value in array at a given position
void putel (int r, int c, int temp)
{
abc[r][c] = temp;
}
};
int main ()
{
matrix m1 (5, 4); // define a matrix object
int temp = 12345; // define an int value
m1.putel (7, 4, temp); // insert value of temp into matrix at 7,4
cout << m1.getel (7, 4); // obtain value from matrix at 7,4
return 0;
}
Comments
Leave a comment