What are required functions and member functions to enable the following program producing the correct result.(Only need to write the declarations for functions and member functions).
#include <iostream>
using namespace std;
class cat { friend istream& product>>(istream &a,cat &b); private: int row, col,colc, *data;
friend ostream& product<<(ostream& a, cat &b);
public: cat() { row = col = 0; data = 0;
}
cat(int r, int c) {row = r; col = c; data = new int [row*col];}
cat(cat &a ) { row=a.row; col = a.colc; data = new int [row*col];
for (int i=0; i< row*col; i++) data[i]=a.data[i];
}
~cat()
{
if (data !=0) delete [] data;
}
void showMatrix()
{
int w=0, j;
for (int i = 0; i<row; i++)
{
for (j=0; j<col; j++)
{
cout<<data[w] << ' '; w++;
}
cout<<endl;
}
cout <<endl;
} };
cat product(cat &a, cat &b)
{
cat tmp( a.row, b.col);
int s, i, j;
for (i=0; i<a.row; i++)
for (j=0; j<b.col; j++)
for (tmp.data[i*b.col+j] = 0, s=0; s<a.col; s++)
tmp.data[i*b.col+j] +=a.data[i*a.col+s]*b.data[s*b.col+j];
return tmp;
}
int main() { int m, n ,k;
cout<< "enter row no. of the matrix A: "; cin >>m;
cout<<"enter column no. of the matrix A: "; cin >>n;
cout<<"enter column no. of the matrix B: "; cin >>k; cat a (m, n); cat b(n, k);
istream& product>>(istream &a,cat &b); ostream& product<<(ostream& a, cat &b); cat c; c=a* b; ostream& product<<(ostream& c);
system("pause");
return 0;
}