Question: swapper.cpp : /************************* program: swap two integers **************************/ #include using namespace std; void swapper (int & x, int & y); int main() { int myx=3,

swapper.cpp : /************************* program: swap two integers **************************/ #include using namespace std;swapper.cpp :

/************************* program: swap two integers **************************/ #include using namespace std; void swapper (int & x, int & y); int main() { int myx=3, myy=4; cout   Part 1 --Function Templates  Copy this file to your computer. The file: swapper.cpp swapper. cpp contains a "swapper" function that will swap two integer values Your primary tasks for this exercise are: 1. Create a function template which will swap two values of any type. 2. Create a function template which will print any two values passed to it. Steps include:  Convert the function "swapper" (from swapper. cpp) into a templated function. . Try and use it for swapping integers. Build and Run the executable.  Now, create another templated function which will print any two values passed to it. You can name it "printem".  Add a call to "printem" before and after the call to your swap routine (replacing the current "cout" statements). Build and Run the executable.  Add variable pairs of different types so that your program can handle o int o char o double Include "swapper" and "printem" calls to ensure that these functions are working for these types as well. Build and Run the executable. Your output should look something like the following: First Value is: 3 Second Value is: 48 AFTER SWAP First Value is: 48 Second Value is: 3 First Value is: 5.5 Second Value is: 8.5 AFTER SWAP First Value is: 8.5 Second Value is: 5.5 First Value is: a Second Value is: b AFTER SWAP First Value is: b Second Value is: a Press any key to continue

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!