Question: C++ Lab6a We've seen two ways we can write a function that swaps the values of two int variables: one way passes the ints by

C++ Lab6a We've seen two ways we can write a function that swaps the values of two int variables: one way passes the ints by reference, the other way passes the addresses of those ints. Write a swap function that uses both - it should pass one int variable by reference, and should pass the address of the other int variable, and the function should then swap those two values. Write a main function that declares and initializes two int variables, calls your swap function, and then prints out the two variables, showing that their values were correctly swapped.

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!