SlideShare a Scribd company logo
Avani Nakum
(180043107016)
One of the more powerful features for code
readability is that of overloading.
Function overloading is the availability of
various functions within a class that differ
from each other in function signature i.e.
various functions share same name with
different parameter types or number of
parameters.
Define multiple functions with the same
name differing in the number of arguments
passed.
We use function overloading/method
overloading for the purpose of:
1. Compile time binding
2. Better Consistency
3. Better Readability
In this type of overloading we define two or
more functions with same two or more
function with same name and same
number of parameters, but the type of
parameter is different. For example in this
program,we have two sum() function, first
one gets two integer arguments and
second one gets two double arguments.
 int sum(int x, int y)
{
cout<<x+y;
}
double sum(double x,
double y)
{
cout<<x+y;
}
int main()
{
sum(10,20);
sum(10.5,20.5);
}
Overloaded functions are distinguished by
their signatures.
A signature is a combination of function’s
name and its parameter types.
The compiler uses only parameter list to
distinguish between functions of same
name.
1) Each overloaded function must differ either
by the number of its formal parameters or
their data types.
2) The return type of overloaded functions may
not be the same data type.
3) The default arguments of overloaded
functions are not considered by the c++
compiler as part of the parameter list.
4) Do not use the same function name for two
unrelated functions improper declarations
leading to conflict in a function call
statement.
void fun (char a, int times)
{
for (int i=1; i<=times; i++)
cout<<a;
}
Void fun (char a=“*” ,int times)
{
for(int i=1; i<=times; i++)
cout<<3;
}
Void fun (int times)
{
for(int i=1;i<=times; i++)
cout<<“@”;
}
Void main()
{
fun(‘+’ , 60);
fun(60);
}
THANK
YOU…!!!

More Related Content

ODP
Functions & closures
PPT
Strings In OOP(Object oriented programming)
PPT
Strings Arrays
PPT
Object Range
PPTX
Double pointer (pointer to pointer)
PPTX
Pointers
Functions & closures
Strings In OOP(Object oriented programming)
Strings Arrays
Object Range
Double pointer (pointer to pointer)
Pointers

What's hot (19)

PPTX
Array of pointer
PPTX
Chapter 16 Dictionaries
PDF
Python strings
PDF
Function overloading
PPS
Wrapper class
PPTX
Variable and constants in Vb.NET
PPTX
Python programming –part 7
PPTX
Keywords, identifiers and data type of vb.net
PPTX
An Introduction : Python
PPTX
Python programming- Part IV(Functions)
PDF
C++ Version 2
PPTX
Pointers Refrences & dynamic memory allocation in C++
PPTX
Introduction to Python Basics
PPTX
Python programming –part 3
PDF
StringTokenizer in java
PPTX
String in python lecture (3)
PDF
C++ version 1
PPTX
Parts of python programming language
PPTX
Iteration
Array of pointer
Chapter 16 Dictionaries
Python strings
Function overloading
Wrapper class
Variable and constants in Vb.NET
Python programming –part 7
Keywords, identifiers and data type of vb.net
An Introduction : Python
Python programming- Part IV(Functions)
C++ Version 2
Pointers Refrences & dynamic memory allocation in C++
Introduction to Python Basics
Python programming –part 3
StringTokenizer in java
String in python lecture (3)
C++ version 1
Parts of python programming language
Iteration
Ad

Similar to function overloading (20)

PPTX
Function overloading
PPTX
Functions in C++ (OOP)
PPTX
Presentation on polymorphism in c++.pptx
PPT
Function overloading in c++
PPT
OODP UNIT 2 Function overloading
PDF
03 function overloading
PPT
3 Function Overloading
PPT
FunctionOverloadingwithpolymorphismconcept.ppt
PPT
class12 3 Function Overloadingin ooooop .ppt
PPTX
Lecture 4, c++(complete reference,herbet sheidt)chapter-14
PPTX
Silde of the cse fundamentals a deep analysis
PPTX
Function overloading
PPTX
Function overloading and overriding
PPTX
2CPP11 - Method Overloading
PPTX
6. Functions in C ++ programming object oriented programming
PPTX
Functions in C++ programming language.pptx
PPTX
Function overloading
PPTX
C++ FUNCTIONS-1.pptx
PPTX
Function Overloading Call by value and call by reference
PPTX
FUNCTIONS, CLASSES AND OBJECTS.pptx
Function overloading
Functions in C++ (OOP)
Presentation on polymorphism in c++.pptx
Function overloading in c++
OODP UNIT 2 Function overloading
03 function overloading
3 Function Overloading
FunctionOverloadingwithpolymorphismconcept.ppt
class12 3 Function Overloadingin ooooop .ppt
Lecture 4, c++(complete reference,herbet sheidt)chapter-14
Silde of the cse fundamentals a deep analysis
Function overloading
Function overloading and overriding
2CPP11 - Method Overloading
6. Functions in C ++ programming object oriented programming
Functions in C++ programming language.pptx
Function overloading
C++ FUNCTIONS-1.pptx
Function Overloading Call by value and call by reference
FUNCTIONS, CLASSES AND OBJECTS.pptx
Ad

Recently uploaded (20)

PDF
composite construction of structures.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Geodesy 1.pptx...............................................
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT
Mechanical Engineering MATERIALS Selection
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
PPT on Performance Review to get promotions
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Well-logging-methods_new................
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
composite construction of structures.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Geodesy 1.pptx...............................................
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Mechanical Engineering MATERIALS Selection
Embodied AI: Ushering in the Next Era of Intelligent Systems
Foundation to blockchain - A guide to Blockchain Tech
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPT on Performance Review to get promotions
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
UNIT 4 Total Quality Management .pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Well-logging-methods_new................
CH1 Production IntroductoryConcepts.pptx
bas. eng. economics group 4 presentation 1.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...

function overloading

  • 2. One of the more powerful features for code readability is that of overloading. Function overloading is the availability of various functions within a class that differ from each other in function signature i.e. various functions share same name with different parameter types or number of parameters.
  • 3. Define multiple functions with the same name differing in the number of arguments passed.
  • 4. We use function overloading/method overloading for the purpose of: 1. Compile time binding 2. Better Consistency 3. Better Readability
  • 5. In this type of overloading we define two or more functions with same two or more function with same name and same number of parameters, but the type of parameter is different. For example in this program,we have two sum() function, first one gets two integer arguments and second one gets two double arguments.
  • 6.  int sum(int x, int y) { cout<<x+y; } double sum(double x, double y) { cout<<x+y; } int main() { sum(10,20); sum(10.5,20.5); }
  • 7. Overloaded functions are distinguished by their signatures. A signature is a combination of function’s name and its parameter types. The compiler uses only parameter list to distinguish between functions of same name.
  • 8. 1) Each overloaded function must differ either by the number of its formal parameters or their data types. 2) The return type of overloaded functions may not be the same data type. 3) The default arguments of overloaded functions are not considered by the c++ compiler as part of the parameter list. 4) Do not use the same function name for two unrelated functions improper declarations leading to conflict in a function call statement.
  • 9. void fun (char a, int times) { for (int i=1; i<=times; i++) cout<<a; } Void fun (char a=“*” ,int times) { for(int i=1; i<=times; i++) cout<<3; } Void fun (int times) { for(int i=1;i<=times; i++) cout<<“@”; } Void main() { fun(‘+’ , 60); fun(60); }