William S.

asked • 04/30/21

How to Complete a Swap() Function while Using Other Functions from Other Files (C++)

Complete the Swap() function in main.cpp to exchange the values of the num field of two Number objects, num1 and num2. Since both num1 and num2 are changed inside Swap(), reference operators (&) are used to pass num1 and num 2 by reference.


Hint: Refer to the given Number class to see the definitions of num field and other functions available.


Ex: If num1 is 19 and num2 is 178, calling Swap(num1, num2) will swap the values so that num1 becomes 178 and num2 becomes 19.


Links to images of the source code files are given below:


Main.cpp (Finish defining Swap() function)

https://imgur.com/a/UcjxRPq


Number.cpp (READ ONLY)

https://imgur.com/a/iu3PBbJ


Number.h (READ ONLY)

https://imgur.com/a/xgCHh2b


1 Expert Answer

By:

Patrick B. answered • 05/01/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.