Write a c++ program to add andmultiply elements in two arrays. Use operator over
ID: 3614477 • Letter: W
Question
Write a c++ program to add andmultiply elements in two arrays. Use operator overloading foraddition
and multiplication using two friendfunctions. Also the size of each array should bespecified
dynamically by entering them from console,and the size of array should be set during the
construction of an object. If the two arrayshave different sizes, then you can just copy the restof
the elements into a result object. Finally,use the ">>" operator overloading to enter theelements
of the array, and use "<<" operator overloading to outputthe results of addition and multiplication.
Explanation / Answer
Alright, I have made some C++ code for you to get most of the job done, butI have left stuff out so that way you do not plagiarize the wholecode I give. Although it shouldn't be too hard to fill in therest. --------------------------- #include using namespace std; class myOps { int *x; int s; public: myOps() { x = newint; s =3; // You will have to figure out how to set the array sizefor your new variable } myOps(int *i, int size) { x = i; s =size; } myOps operator+(myOpsop); myOps operator*(myOpsop); myOps operator=(myOpsop); void show(); }; myOps myOps::operator+(myOps op) { myOps temp; // Loop through both arrays and store the sum inyour variable for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.