CONSTRUCTING MATRIX OBJECTS
<iostream>
using namespace std;
class matrix
{
**p;
d1,d2;
:
matrix( x,y);
get_element( i,j,value)
{
p[i][j]=value;
}
& put_element( i, j)
{
p[i][j];
}
};
matrix::matrix(x, y)
{
d1=x;
d2=y;
p=new int *[d1];
( i=0; i < d1;i++)
{
p[i]=new int[d2];
}
}
main()
{
m,n;
std::cout<< "Enter size of matrix";
std::cin>> m >> n;
matrix A(m,n);
cout << "Enter matrix elements row by row \n";
i,j,value;
(i=0;i < m;i++)
{
(j=0;j < n;j++)
{
std::cin>> value;
A.get_element(i,j,value);
}
}
std::cout<< "\n";
std::cout<< A.put_element(1,2);
};
|