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...


Create a new file (in Dev C++) and save it aslab11_XYZ.cpp (replace XYZ with your initials).


Create ANOTHER new file (in Dev C++) and save it asswap_XYZ.h (replace XYZ with your initials).


Use theswap_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. Usedouble quotes instead of angle brackets. Make sure the header file (H file) is located in thesame folder as the CPP file.


#include #include "swap_XYZ.h"


using namespace std;


Write adriver 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 messageconsider using displayMessage()!

  • for each version of swap(),

    • provide or prompt for two itemsconsider using prompt()!

    • display which version is being called

    • display values before swap

    • call swap function

    • display values after swap



  • display a goodbye messageuse displayMessage() again!


Submit the completed H file and the completed CPP file (not the EXE file) back to this assignment

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here