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?

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!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

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

Q: Explain how the minimum-sum descent problem can be solved by Dijkstra’s algorithm.    This is a prob...

A: The problem is to find the solution of minimum-sum descent  problem is relatively simple using Top-t...

Q: I dont understand whats going on Its hard for me to read whats happening and what the output will be...

A: Click to see the answer

Q: What are the benefits of using a vector over an array?

A: Vector - It is a data structure used to store data.Vectors can be implemented as dynamic arrays with...

Q: Using DeMorgan's Law, write an expression for the complement of F ifF(x,y,z) = xz' (xy + xz)+ xy'(wz...

A: DeMorgan’s law:The theorems of DeMorgan are basically two sets of rules or laws developed for AND, O...

Q: Suppose that you want to solve a maximum flow problem containing parallel arcs, but the maximum flow...

A: Maximum Flow ProblemMaximum flow problem is a problem that invloves finding a feasible flow through ...

Q: A two-dimensional random walk simulates the behavior of a particle moving in a grid of points. At ea...

A: A java program that takes an integer command-line argument “n” and simulates the motion of a random ...

Q: In C++: Trace all the passes for the selection sort on the array: { 22, 65, 9, 15, 55, 27, 33, 45}

A: Selection sort:The selection sort algorithm sorts an array by finding the minimum element from the u...

Q: What is the mantisa and exponent value if 6.75 represnt in 8 bit binary floating point

A: The mantissa and exponent value of 6.75 can be obtained by converting the given decimal number into ...

Q: "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the...

A: Program Algorithm-STARTStep1:Import the essential headers.Step2: Declare the main function.Step3: De...

Q: If a non-key column determines a key column, which normal form is violated?A) 1NFB) 2NFC) 3NFD) BCNF

A: BCNF:Boyce – Codd Normal Form (BCNF) is based on functional dependencies that in a relationship all ...

Q: Why does the order of the operands (tables) matter in an EXCEPT (MINUS) query but not in a UNION que...

A: MINUSMINUS operator is used for getting the result that is present in the first table but not in the...

Q: NOTE: in mathematics, the square root of a negative number is not real; in C++ therefore, passing su...

A: A C++ program is to be created  that will read the value for area of square and will print the lengt...

Q: How did Cisco systems solve physical security problems?

A: Cisco is a US-based technology corporation best known for its networking services. As a company that...

Q: Write a wholly creative quiz program that consists of three original questions that you make up acco...

A: Error in the program-Remove the points variable after each fragment of code except the point variabl...

Q: Algorithm problem w/ recurrence: Frying pancakes: a small pan can only hold two pancakes at a time. ...

A: Let T(n) be the time required to fry n pancakes on both the sides.Given condition:If n=1, time requi...

Q: Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4...

A: Create a java program to pre-sell the cinema ticket.The name of the program is TicketSeller.The maxi...

Q: Many documents use a specific format for a person's name. Write a program whose input is: firstName ...

A: This program can be done in a very easy way. Programming instruction: First, take the input from the...

Q: Create a subclass of Vehicle called Car. Car should have additional attributes of: make (String)mode...

A: Creation of subclass “Car” which is extended from “Vehicle” class:The "Car" subclass contains "make"...

Q: My prompt for my C++ problem is to write a program that accepts command line arguments and to print ...

A: Create a C++ program which will shows either true or false for first and last string character.Progr...

Q: what is the difference between authentication and authorization? Can a system permit autorization wi...

A: Authentication: ⦁ Authentication means the system is going to grant access to any individual by veri...

Q: Add each element in origList with the corresponding value in offsetAmount. Print each sum followed b...

A: Completing the given C++ program so, that it can follow the given rubrics:Two vector, origList and o...

Q: Write a program that displays the income tax due on taxable income entered by the user. Have the use...

A: The program that displays the income tax due on taxable income is created in java.In calTax() method...

Q: In C++ Language (please use hint) : Write a function which will swap its arguments if the first argu...

A: Call by reference: In this approach, passing the arguments to a method copies the address or referen...

Q: In MS Access, to ensure that a grade must be either A, B, C, D or F, whichvalidation rule should be ...

A: Microsoft (MS) AccessMicrosoft access is a database management system from Microsoft that combines r...

Q: DISCUSS THE BLOCKCHAIN TECHNOLOGY?

A: What is BLOCKCHAIN: ⦁ As its name suggests, its a chain of blocks or a growing list of records (reco...

Q: Python 3.7.4 Write a statement that associates d with a one-entry dictionary that maps the str 'answ...

A: The required statement is as given below:d = {'answer':42}

Q: OF 2019 x + X PG Difference between two given ti https://moodle.oakland.edu/plug X fn Course: CSI-14...

A: Program in C to calculate the order price by entering number of books, price of a book, tax per book...

Q: Create a new file (in Dev C++)  In Lab 2, you created a menu for a simple calculator program. In Lab...

A: Program AlgorithmDeclare the required variables and write a welcome message before starting the menu...

Q: Create reports containing the following details from the database: Q1 How many books are there in th...

A: SELECT category, count(category) AS "numberOfBooks",FROM booksWHERE category='computer'; The above q...

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

A: The following is the source code which takes the input from the user and tells whether the input yea...

Q: Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest r...

A: The following source code will perform the functions as specified in the question.

Q: Find the truth table that describes the following circuit.

A: The given circuit diagram shows operations for each gate. The final Boolean expression found through...

Q: What security technology did Cisco deployed to control building security?

A: According to STS (Security, technology and System) team the more important challenges that are suppo...

Q: Shipping is free for online orders totaling $25 or more at Mississippi.com. Orders less than $25 are...

A: Note: You didn't mention any language so i use Python#get the inputs from the userunit_cost = float(...

Q: a. Construct a Huffman code for the following data: Symbol A L I Z P Frequency 4.5 .5 3.0 1.0 1...

A: a)Constructing Hauffman code for the given data:

Q: Let F = (V; A) be a digraph. Show that if u is k-edge-connected to v and v is k-edge-connected to w,...

A: Connectivity:To measure the connectedness of a digraph ‘F’, consider the minimum number of vertices ...

Q: Hello! I am new to Java and am struggling heavily with a current assignment. I got the output to loo...

A: Program: import java.util.Scanner;import java.math.RoundingMode;import java.text.DecimalFormat;publi...

Q: I need help with this programming exercise:   Write a C++ console application that allows your user ...

A: Program code #1:

Q: Too Many Networks While attempting to connect to the wireless network at your job, you notice that f...

A: Selecting the appropriate wireless network:The user can determine the wireless network to which he/s...

Q: Hi, I just finished the code for writing a java program that accepts ingredients for a recipe in cup...

A: Begin the pseudocode with the description/goal of the program.Indent loop and condition constructs p...

Q: What is the typical size of the security staff in a small organization? A medium-sized organization?...

A: Answer:Size of security staff in a small organization:The size of the security staff in a small-size...