Overloading: There are many simple definition of Overloading like:
1: In overloading function with same name having different parameters.
2: Function overloading may have different return types.
Let’s write a Simple program to Overload.
//Code:
#include<iostream.h> #include<conio.h> class add { public: void sum(int x,int y) { cout<<x+y; } void sum(int x,int y,int z) { cout<<x+y+z; } }; void main() { clrscr(); add t; t.sum(10,20) cout<<”\n\n”; t.sum(10,20,30); getch(); }
Now run the program and see output:
output:
Happy coding…