0% found this document useful (0 votes)
23 views

Function Overloading. Nab 3

Uploaded by

Nandini Kasi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Function Overloading. Nab 3

Uploaded by

Nandini Kasi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

…FUNCTION OVERLOADING...?

 function overloading is defined as the process having


two or more function with the same name,but different
parameters is know as function overloading in c++
In function overloading function is redefined by using
either different types of arguments or a different
number of arguments…
Function overloading is also called as compile time
polymorphism…
SYNTAX:-

1. CLASS CLASS_NAME
2. {
3. PUBLIC:-
4. VOID ADD ()
5. }
6. }
7. VOID ADD (int a)
8. {
9. }
10. };
EXAMPE PROGRAM:-
1. #INCLUDE <IOSTREAM> • Void fun (int a,int b)
2. Using namespace std; • {
3. Class A • Int sub=a-b;
4. { • Cout<<‘’substraction’’<<sub<<endl;
5. Int num1=20,num2=10; • }
6. public • };
7. void fun() • Int main()
8. { • {
9. Int sum=num1+num2; • A obj;fun();obj.fun(100,50);
10. cout <<‘’addition’’<<sum<<endl; • return 0;
11. } • }
output:-
Addition 30
Substraction 50
ADVANTAGES:-

1. THE PROGRAM IS VERY SIMPLE AND ALSO


EASIER TO UNDERSTAND
2. IT SAVES THE MEMORY SPACE MAINTAINS
CONSISTENCY
3. FUNCTION OVERLOADING EXECUTES THE
PROGRAM FASTER
4. FUNCTION OVERLOADING IS USED FOR
CODE REUSABILITY….
DISADVANTAGES:-
• THE FUNCTION WITH RETURN TYPES
CAN’T BE OVERLOADED
• THE SAME PARAMETERS OR THE
SAME NAMES TYPES CANNOT BE
OVERLOADED.
…THANK YOU….
D

You might also like