Question: In Java, we were unable to write methods to swap the values of two variables because everything in Java is pass - by - value:

In Java, we were unable to write methods to swap the values of two variables because everything in Java is pass-by-value: local variables inside of the method are copies of the variables that were passed in. In C++, however, we can take advantage of pass-by-reference to finally implement a swap function!
Task: Edit Swap.cpp
In this part of the assignment, we have provided a file called Swap.cpp that is currently essentially blank. In this part of the assignment, you will fill in the code in order to write a global function called swap that swaps the values of two int arguments. Be sure to only modify Swap.cpp: do not modify Swap.h.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!