Create a new file (in Dev C++) and save it as lab11_XYZ.cpp (replace XYZ with your initials). Create ANOTHER new file (in Dev C++) and save it as swap_XYZ.h (replace XYZ with your initials). Use the swap_XYZ.h header file to define a set of functions for swapping two items of the same type. Given the following prototypes, define (overloaded) swap functions void swap(int&, int&); //swap two integers void swap(double&, double&); //swap two doubles void swap(float&, float&); //swap two floats void swap(char&, char&); //swap two characters void swap(string&, string&); //swap two strings The header file should contain the following: header comments (similar to normal program header comments) function definitions (for you to do, based on provided prototypes above...) In general, a swap works like this: void swap(type first&, type second&){ type temp = first; first = second; second = temp; } Once your header file is complete, make sure to include it in your main CPP program. Use double quotes instead of angle brackets. Make sure the header file (H file) is located in the same folder as the CPP file. #include <iostream>#include "swap_XYZ.h" using namespace std; Write a driver program to test your header file. The program should test each version of the swap function and display the results. The program should: display a hello message consider using displayMessage()! for each version of swap(), provide or prompt for two items consider using prompt()! display which version is being called display values before swap call swap function display values after swap display a goodbye message use displayMessage() again! Submit the completed H file and the completed CPP file (not the EXE file) back to this assignment
Create a new file (in Dev C++) and save it as lab11_XYZ.cpp (replace XYZ with your initials).
Create ANOTHER new file (in Dev C++) and save it as swap_XYZ.h (replace XYZ with your initials).
Use the swap_XYZ.h header file to define a set of functions for swapping two items of the same type.
Given the following prototypes, define (overloaded) swap functions
- void swap(int&, int&); //swap two integers
- void swap(double&, double&); //swap two doubles
- void swap(float&, float&); //swap two floats
- void swap(char&, char&); //swap two characters
- void swap(string&, string&); //swap two strings
The header file should contain the following:
- header comments (similar to normal program header comments)
- function definitions (for you to do, based on provided prototypes above...)
In general, a swap works like this:
void swap(type first&, type second&){ type temp = first; first = second; second = temp;
}
Once your header file is complete, make sure to include it in your main CPP program. Use double quotes instead of angle brackets. Make sure the header file (H file) is located in the same folder as the CPP file.
#include <iostream>#include "swap_XYZ.h"
using namespace std;
Write a driver program to test your header file. The program should test each version of the swap function and display the results.
The program should:
- display a hello message consider using displayMessage()!
- for each version of swap(),
- provide or prompt for two items consider using prompt()!
- display which version is being called
- display values before swap
- call swap function
- display values after swap
- display a goodbye message use displayMessage() again!
Submit the completed H file and the completed CPP file (not the EXE file) back to this assignment

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images









