Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please complete the code in c++ and use the instructions given, thanks f/fillenanei arrayaddder, CFp /Modify this progran to overlood subtraction operator and insertion operator
please complete the code in c++ and use the instructions given, thanks
f/fillenanei arrayaddder, CFp /Modify this progran to overlood subtraction operator and insertion operator Hinclude clostreder? irsing nasespace std; aulefine maxarray 5 class myarray private: int value[ [AYARRAY] public: vold setvalue(int index, int neivalue)( value[ [ndex]=newvalue;] Int getvalue(int index) ? return value[index]i] myarray operatoct(myarray array 2 ) nyarray temparray; for (Int lue; ilmaxabeny; int) temparroy value[1] madue[1] 4 arroy 2 ,volve[1]; return tenparrayi lntman(}) myarray aerayl, array2, array3z Int 17 f/TNItal12E for \{ i.0: I Chaxariy; f++} array 1 . vetvalue (1,1); array? Aetualue (2,1+3) i putiler Yoid setvalue(int index, int nrwvalue of value [ index]-newvalur:) Int netwalue(int index) retiern walue [index] if yarray operatort (myarrmy arraya) *yarray Ermarray: fon (ies f-e) rotwotastri 2+ ) tewparrayivalue [i]-yalue [1]+ array? -value[1]: returnjteepinoy: int main () Ayarray arpayi, arrayd, arrwy 3: ine is (itNirfatise arraydisetvalue (1,1)} array2, setvalue (1,1+3)f Yrape array a array1 + arrayz l/eBtNT cout is "arrayl array2 arrayz" ce endli for { feed ielixadady f+t} cout or arrayl-getvalue ($)ce= array2igetyalue(i) (1) ce:endli return of Your primary lasks for this exercise are: 1. Modify the code so that you overioad the "- operator to subtract array2 from array1 - First ovorload it as a member function in the myarrivy cliss - Second overload it as a non-member function 2. Overioad the "ss" (insertion operator) so that it will print the entire array on one line Steps inciude - Build and run the execulable file (this is just to ensure that the program is workng) You should g - Add some code in the syarray class to overload the "" operator - Add some code in main (after the following line) - Add some code in the myarray class to cvorload tho =o eperalor. - Add seene code in main (aftes tho following line) to subtract array2 from array1 (and store the resuit in array3). Build and run the executable file. You shoukd got the foliowing output - Overload the "= operator as an non-member (friend) function. (Making approprate changes- ass in this section) Build and run the executable file You should get the same output as the previous fun. - Now, overioad the "eec" (insertion operator) so that it will print one array por line Hints: The prototype will look like this: - Now, overiond thor "se" (insertion operator) so fleat it wifl print one acray por livo. Hats The probotype will look like thes: batrean iperaterec(ouerrank ot, wyarray array) You make use of os in tines like the folkeving (thes puts "newartay " into the oulput stream, os) Dory finget fo return:os 3 - Change the calls to cout in main so that you only have as single line, cout of arrayl we arrayz of arrayy! - Build and run the executable file. You should get output similar to the following. When you are finished you should have: 1 The subtraction operator overloaded as a member but commented out When you are finished you should have: 1. The subtracton operator overioaded as a member, but commonted out 2. Ther subtriction operalor overloaded as a non-member 3. The ostrearn insertion sperator cc overlouded 4 Both tables filled in on README md Please pay attention to the rotian typos - not ervnry cperator returns a "riyartuy" obyet Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started