Presentation is loading. Please wait.

Presentation is loading. Please wait.

Function Overloading. 2 Function Overloading (Function Polymorphism) Function overloading is a feature of C++ that allows to create multiple functions.

Similar presentations


Presentation on theme: "Function Overloading. 2 Function Overloading (Function Polymorphism) Function overloading is a feature of C++ that allows to create multiple functions."— Presentation transcript:

1 Function Overloading

2 2 Function Overloading (Function Polymorphism) Function overloading is a feature of C++ that allows to create multiple functions with the same name, but they have different parameters But overloading of functions with different return types are not allowed. The biggest advantage of overloading is that it helps us to perform same operations on different data types without having the need to use separate names for each version.

3 3 Function Overloading (Function Polymorphism) When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call. Eg: Void fun(int x,int y) Void fun(float x,float y) Void fun(float x,int y, char z) Void fun(char x, float y, int z)

4 4 Function Overloading (Function Polymorphism) Questions Swap 2 integers, 2 float and 2 char Find volume of cube, cylinder and rectangular box

5 5 Function Overloading (Function Polymorphism) Volume Cube  s*s*s Cylinder  3.14*r*r*h Rectangular box  l*b*h


Download ppt "Function Overloading. 2 Function Overloading (Function Polymorphism) Function overloading is a feature of C++ that allows to create multiple functions."

Similar presentations


Ads by Google