friend function using c++ program

// FRIEND FUNCTION
#include
#include
class matrix
{
private:
int a[5][5],c[5][5];
public:
int m,n;
void input();
friend matrix operator*(matrix m1,matrix m2);
void display();
};
void matrix::input()
{
cout<<"enter the no of rows";
cin>>m;
cout<<"enter the no of columns";
cin>>n;
cout<<"enter the elements of matrixA \n";
for(int i=0;i {
for(int j=0;j {
cin>>a[i][j];
}
}
}
matrix operator*(matrix m1,matrix m2)
{
matrix m3;
int i,j;
for(i=0;i {
for(j=0;j {
m3.c[i][j]=0;
for(int k=0;k<2;k++)
{
m3.c[i][j]=m3.c[i][j]+m1.a[i][k]*m2.a[k][j];
}
}
}
return(m3);
}
void matrix::display()
{
cout<<" \n";
cout<<"the product of both matrix is \n";
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
cout< }
cout< }
}
void main()
{
matrix m1,m2,m3;
clrscr();
m1.input();
m2.input();
m3=m1*m2;
m3.display();
getch();
}

Comments