#include<iostream> using std::cout; using std::cin; using std:: ostream; using s
ID: 3614645 • Letter: #
Question
#include<iostream>
using std::cout;
using std::cin;
using std:: ostream;
using std::istream;
using std::endl;
class myOps
{
public:
int *x;
int s;
myOps()
{
x = new int;
s = 100;
}
myOps(int *i, intsize)
{
x = i;
s = size;
}
friend myOpsoperator+(myOps&, myOps&);
friend myOpsoperator*(myOps&, myOps&);
myOps operator=(myOpsop);
friend ostream&operator<<(ostream& ,const myOps&);
friend istream&operator>>(istream& ,const myOps&);
};
myOpsoperator+(myOps& op1, myOps& op2)
{
myOps temp;
for(inti = 0; i < op1.s; i++)
{
temp.x[i] = op1.x[i] +op2.x[i];
}
return temp;
}
myOps operator*(myOps& op1, myOps& op2)
{
myOps temp;
for(inti = 0; i < op1.s; i++)
{
temp.x[i] = op1.x[i] *op2.x[i];
}
return temp;
}
myOpsmyOps::operator=(myOps op)
{
x = op.x;
return *this;
}
ostream&operator<<(ostream& os, const myOps& mp){
for(inti=0;i<mp.s;i++){
os<<mp.x[i]<<endl;}
return os;
}
istream&operator>>(istream& is, const myOps& mp){
for(inti=0;i<mp.s;i++){
cout << "Arrayelement["<<i<<"] : ";
is>>mp.x[i];
}
returnis;
}
int main()
{
int size1, size2;
cout << "Array Size One: ";
cin >> size1;
cout << "Array Size Two: ";
cin >> size2;
cout <<endl;
int big= size2;
if(size1>size2)
big=size1;
intconst size=big;
int *num1 = new int[size1];
int *num2 = new int[size2];
int *result= new int[size];
myOpsa(num1,big), b(num2,big),c(result,big);
myOpsd(result,big),e(num1,size1),f(num2,size2);
cout<<"Please enter the first arrayelements"<<endl;
cin >>e;
cout<<"Please enter the second arrayelemnents"<<endl;
cin>>f;
cout<< endl;
d=a+b;
cout << " Addition result : ";
cout<<d;
cout << " Multiplication result : ";
c = a * b;
cout<<c;
return 0;
}