Question: Function Overloading Objectives After you complete this experiment you will be able to implement function overloading in a C++ program. Introduction Function overloading occurs when
Function Overloading
Objectives
After you complete this experiment you will be able to implement function overloading in a C++ program.
Introduction
Function overloading occurs when two or more functions have the same name but different formal parameter lists. The compiler only uses the function signatures to identify a function in function overloading. Never consider the function return type.
More information on function overloading can be found in your course textbook and on the web.
Experiments
Step 1: In this experiment you will learn how to implement function overloading.
Enter, save, compile and execute the following program in MSVS. Call the new project FunctionOverloadingExp and the program FunctionOverloading.cpp. Answer the questions below:
#include
#include
using namespace std;
void swap(string &a, string &b)
{
string temp = a;
a=b;
b=temp;
}
void swap(int &a, int &b)
{
int temp = a;
a=b;
b=temp;
}
void swap(char &a, char &b)
{
char temp = a;
a=b;
b=temp;
}
int main()
{
string x="111", y="222";
char r='1', s='2';
int a=111, b=222;
cout<<"original strings: x = "<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
