SlideShare a Scribd company logo
4
Most read
5
Most read
G.BALAJI MCA,M.Tech.,
Assistant Professor Of Computer Science,
Vivekanada College,Madurai.
 In C language we cannot make functions using same
name. But in C++ we can use function with same
name.
 For eg:
void add();
int add();
In C language, It’s not allowed in functions using
same name in same program
In C++ it’s allowed in same program but this is
wrong too...
They obey the function are some conditions
 Function overloading is defined as two or more functions
having same name but they should be differ in arguments.
 For eg:
Void add();
 Void add(int a);
 int add(double a);
 Void add (int a,int b);
These all are valid functions in the same program.
In this program four function have same name with different
arguments.
Void & int is return type in this program but return type is
doesn’t matter here. Arguments make the functions unique.
# include<iostream>
void add(int a,int b)
{
cout<<“ the addition of two numbers is “<<a+b<<endl;
}
void add(double a,double b)
{
cout<<“ the addition of two numbers is “<<a+b<<endl;
}
void main()
{
int first,second;
double fir,sec;
cout<< “enter two integers”<<endl;
cin>>first>>second; //we take input from user.
add(first,second);
cout<<“ enter two doubles value:”<<endl;
cin>>fir>>sec; //we take input from user.
add(fir,sec);}
In this program,
void add (int a, int b);
void add (double a, double b);
 Two different function with same name & different
arguments.
add (first, second);
add (fir,sec);
 We dont have to specify which function should be run.
 Complier automatically decides depending on types.

More Related Content

PPT
Binary operator overloading
PPT
Unary operator overloading
PPT
Operator overloading in C++
PPTX
Operator overloading
PPT
Operator overloading
PPTX
PPTX
Operator overloading
Binary operator overloading
Unary operator overloading
Operator overloading in C++
Operator overloading
Operator overloading
Operator overloading

What's hot (20)

PPTX
Operator overloading
PPTX
OPERATOR OVERLOADING IN C++
PPTX
Operator overloading and type conversions
PPTX
Operator Overloading
PPT
Lec 26.27-operator overloading
PPTX
operator overloading
PPT
08 c++ Operator Overloading.ppt
PPTX
Operator overloading and type conversion in cpp
PPTX
Functions in c++,
PPTX
operator overloading & type conversion in cpp over view || c++
PPT
14 operator overloading
PDF
06. operator overloading
PPT
Lecture5
PPTX
Operator overloadng
PDF
Operator overloading in C++
PPTX
Unary operator overloading
PDF
Operator overloading
PPTX
Operator overloading
PPTX
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
PPT
Operator overloading
Operator overloading
OPERATOR OVERLOADING IN C++
Operator overloading and type conversions
Operator Overloading
Lec 26.27-operator overloading
operator overloading
08 c++ Operator Overloading.ppt
Operator overloading and type conversion in cpp
Functions in c++,
operator overloading & type conversion in cpp over view || c++
14 operator overloading
06. operator overloading
Lecture5
Operator overloadng
Operator overloading in C++
Unary operator overloading
Operator overloading
Operator overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
Operator overloading
Ad

Similar to Function overloading in c++ (20)

PPTX
function overloading
PPTX
Function overloading
PPTX
Functions in C++ (OOP)
PPT
FunctionOverloadingwithpolymorphismconcept.ppt
PPT
class12 3 Function Overloadingin ooooop .ppt
PPT
3 Function Overloading
PPTX
Functions in C++ programming language.pptx
PPTX
Silde of the cse fundamentals a deep analysis
PPTX
Presentation on polymorphism in c++.pptx
PPTX
Lecture 4, c++(complete reference,herbet sheidt)chapter-14
PDF
03 function overloading
PPT
Function Overloading.ppt
PPT
Material 3 (4).ppt this ppt is about the
PPTX
Functions1
PPTX
6. Functions in C ++ programming object oriented programming
PPTX
Function overloading
PPT
PPT
OODP UNIT 2 Function overloading
PPTX
Function_Overloading_in_CPP its uses and examples.
PPTX
Function Overloading in C++ programming language
function overloading
Function overloading
Functions in C++ (OOP)
FunctionOverloadingwithpolymorphismconcept.ppt
class12 3 Function Overloadingin ooooop .ppt
3 Function Overloading
Functions in C++ programming language.pptx
Silde of the cse fundamentals a deep analysis
Presentation on polymorphism in c++.pptx
Lecture 4, c++(complete reference,herbet sheidt)chapter-14
03 function overloading
Function Overloading.ppt
Material 3 (4).ppt this ppt is about the
Functions1
6. Functions in C ++ programming object oriented programming
Function overloading
OODP UNIT 2 Function overloading
Function_Overloading_in_CPP its uses and examples.
Function Overloading in C++ programming language
Ad

Recently uploaded (20)

PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pre independence Education in Inndia.pdf
Institutional Correction lecture only . . .
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
O5-L3 Freight Transport Ops (International) V1.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
GDM (1) (1).pptx small presentation for students
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Anesthesia in Laparoscopic Surgery in India
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Sports Quiz easy sports quiz sports quiz
Abdominal Access Techniques with Prof. Dr. R K Mishra
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial disease of the cardiovascular and lymphatic systems
PPH.pptx obstetrics and gynecology in nursing
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

Function overloading in c++

  • 1. G.BALAJI MCA,M.Tech., Assistant Professor Of Computer Science, Vivekanada College,Madurai.
  • 2.  In C language we cannot make functions using same name. But in C++ we can use function with same name.  For eg: void add(); int add(); In C language, It’s not allowed in functions using same name in same program In C++ it’s allowed in same program but this is wrong too... They obey the function are some conditions
  • 3.  Function overloading is defined as two or more functions having same name but they should be differ in arguments.  For eg: Void add();  Void add(int a);  int add(double a);  Void add (int a,int b); These all are valid functions in the same program. In this program four function have same name with different arguments. Void & int is return type in this program but return type is doesn’t matter here. Arguments make the functions unique.
  • 4. # include<iostream> void add(int a,int b) { cout<<“ the addition of two numbers is “<<a+b<<endl; } void add(double a,double b) { cout<<“ the addition of two numbers is “<<a+b<<endl; } void main() { int first,second; double fir,sec; cout<< “enter two integers”<<endl; cin>>first>>second; //we take input from user. add(first,second); cout<<“ enter two doubles value:”<<endl; cin>>fir>>sec; //we take input from user. add(fir,sec);}
  • 5. In this program, void add (int a, int b); void add (double a, double b);  Two different function with same name & different arguments. add (first, second); add (fir,sec);  We dont have to specify which function should be run.  Complier automatically decides depending on types.