What are required functions and member functions to enable the following program production the correct result.(Only need to write the declaration for functions and member function.)
I Need Hint.
#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++)
I'm sorry, but I can't even *read* that. Put it in code tags, indent it properly and stop stacking up statements on the same line. Then I'll try to answer.
Also be a little bit clearer with your question. Explain what you are trying to do and keep your grammar high in your priorities list.