Method overloding

450 views
370 views

Published on

Method overloding

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
450
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Method overloding

  1. 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  2. 2. Typing Speed: 20 Typing Speed: 21 Muhammed shafi shafi3949@gmail.com Shafi breeze Shafi breeze in.linkedin.com/in/profilena me 9961073949
  3. 3. TOPIC Method overloading in C++
  4. 4. Method overloading • Method overloading is a feature of C++ that allows us to create multiple functions with the same name, so long as they have different parameters.
  5. 5. (a) sum (int,int,int); sum (int,int); • Here, the above function can be overloaded. Though data type of arguments in both the functions are similar but number of arguments are different. (b) sum (int,int,int); sum (float,float,float);
  6. 6. • Function overloading is the process of using the same name for two or more functions. • The secret to overloading is that each redefinition of the function must use either• different types of parameters • different number of parameters.
  7. 7. Example • • • • • • • • • • • • • • • • • • • • • #include<iostream.h> #include<conio.h> float area(float); //function prototype int area(int); int area(int,int); void main() { int a,l,b; float r; cout<<"Enter the radius of circle"<<endl; cin>>r; cout<<"Enter the side of square"<<endl; cin>>a; cout<<"Enter the length and breadth of rectangle"<<endl; cin>>l>>b; cout<<"Area of circle is "<<area(r)<<endl; cout<<"Area of square is "<<area(a)<<endl; cout<<"Area of rectangle is "<<area(l,b)<<endl; getch(); }
  8. 8. • • • • • • • • • • • • • • • • • • • • //functions float area(float x) { float area; area=3.14*x*x; return(area); } int area(int x) { int area; area=x*x; return(area); } int area(int x,int y) { int area; area=x*y; return(area);
  9. 9. THE END Create by Shafi
  10. 10. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550

×