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

Question

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

Expert Answer

Want to see the step-by-step answer?

See Answer

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

See Answer
*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.
Tagged in
EngineeringComputer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: WHAT ARE THE STAKEHOLDERS OF BITCOIN VALUE CHAIN?

A: The stakeholders in bitcoin value chain are:Developers Developers play an important role as they use...

Q: Python 3.7.4: The current calendar, called the Gregorian calendar, was introduced in 1582. Every yea...

A: In order to correct given program, make the following changes:Put def main() code above the def leap...

Q: consider the udp header 12 03 00 0F 00 1E A3 10.What is the total length of the udp

A: The UPD header basically has 4 parts, each part is of 2 bytes. That means following interpretation o...

Q: Hello! I am new to Java and have nearly finished up a project involving a mortgage table, and everyt...

A: According to the question, students need only in output spacing.To display output in proper spacing ...

Q: A transitive dependency is equivalent to which of the following?A) A functional dependency between t...

A: Transitive dependencyA transitive dependency in a database is an indirect relationship between value...

Q: For the following code segment write the machine language representation of each instruction in bina...

A: Instruction 1:

Q: Form boolean equations in POS and SOP forms from the truth table attached (PLEASE EXPLAIN ALL STEPS)...

A: The circuit diagrams that correspond to the following Boolean equations  drawed using an online tool...

Q: whats is the length of UDP?

A: The given User Datagram Protocol header is 12 03 00 0F 00 1E A3 10.The UDP (User Datagram Protocol) ...

Q: Think of one of your Math homework. How can you use program to reveal the answer? Write a calculatio...

A: Variables in PHP: Variables are used to store values like numbers, characters etc. that is of differ...