top of page
Writer's pictureRosario Riley

Function Overloading in C++ with Example

In C++ programming language function overloading is a unique feature that allows you to have multiple functions where you can pass different parameter lists with the same name.



Function overloading follows a simple rule where the function name remains the same even if the list of arguments and their data types are changing. Whenever a function is overloaded and called in the main program, and the actual parameter set and types entered match the syntax of the formal arguments, the function is executed. If no exact match is found, data type promotion (default type conversion) occurs. Conversion from int to float, float to double, and double to char leads to generating errors.

It is a technique in object-oriented programming when two or more functions have the same name, but different parameters. When a function name is overloaded with multiple assignments, then it is said to be function overloading.

When we say parameter list, we mean the data types and order of the parameters. For example, the parameter list of the function my_function(int a, float b) is (int, float), which is different from the parameter list of the function my_function(). float a, int b) (float, int) is different. Function overloading is one type of compile-time polymorphism.

TCCI computer coding institute is located in Bopal Ahmedabad and ISCON Ambli Road in Ahmedabad.

For More Information:

Call us @ +91 9825618292



Recent Posts

See All

Comentarios


bottom of page