Oop1 16789
Oop1 16789
Group Members:
1. ADIYA MASOORA
2. SAMIA IRSHAD
3. SIDRA BIBI
4.EMAN FATIMA
5. MEERAB IFTIKHAR
ADIYA
MASOORA
Roll no : 18
FUNCTION OVERLOADING
DEFINITION:
The process of declaring multiple functions with same
name but different parameters is called overloading.
void add (int , int ); No. of argument same Suppose that we call the add function
void add (int , float ); Type of Argument different Add (10, 20);
The function overloading in the c++ feature is used to improve the readability
of the code. It is used so that the programmer does not have to remember
various function names. If any class has multiple functions with different
parameters having the same name, they are said to be overloaded.
C++ lets you specify more than one function of the same name in the
same scope. These functions are called overloaded functions, or
overloads. Overloaded functions enable you to supply different
semantics for a function, depending on the types and number of its
arguments
SIDRa BIBI
Roll no:23
ADVANTAGES & DISADVANTAGES
Roll no:32
Roll no:36
FUNCTION OVERLOADING THROUGH PROGRAM
PROGRAM:
The parameters should follow any one or more than one of the following
conditions for Function overloading:
•Parameters should have a different type
add(int a, int b)
add(double a, double b)
#include <iostream>
using namespace std;
void add(int a, int b)
{
cout << "sum = " << (a + b);
}
void add(double a, double b)
{
cout << endl << "sum = " << (a + b);
}
// Driver code
int main()
{
add(10, 2);
add(5.3, 6.2);
return 0;
}
Output
sum = 12
sum = 11.5
EMAN
Merab iftikhar
FATIMA
Roll no:36
Roll no:32
PROGRAM:
Following is a simple C++ example to demonstrate function
overloading.
// Importing input output stream files
#include <iostream>
// Methods to print
// Method 1
void print(int i)
{