QUESTION: Design a class in C++ that will overload the Binary Operator * and use it to multiply the corresponding elements of two arrays into a third array.
ANSWER:
ANSWER:
#include
#include
class mat
{
private:
int s[10][10];
int u,v;
public:
void show();
mat Operator +(mat);
mat operator *(mat);
void read();
};
mat mat::operator*(mat uu2)
{
mat t;
t.u=u;
t.v=uu2.v;
for(int i=0;i
for(int j=0;j
{
t.s[i][j]=0;
for(int k=0;k
t.s[i][j]+=s[i][k]*uu2.s[k][j];
}
return t;
}
void mat::read()
{
cout
cin>>u>>v;
cout
for(int i=0;i
for(int j=0;j
cin>>s[i][j];
}
void mat::show()
{
for(int i=0;i
{
for(int j=0;j
{
cout
}
cout
}
}
void main()
{
mat obj1 ,obj2,obj3;
clrscr();
cout
obj1.read();
cout
obj2.read();
obj3=obj1 *obj2;
cout
obj3.show();
getch();
}