Measures Concepts
GitHub icon

Function Overloading

Function Overloading - language feature

< >
// volume of a cube int volume(const int s) { return s*s*s; } // volume of a cylinder double volume(const double r, const int h) { return 3.1415926*r*r*static_cast<double>(h); }
Example from Pascal, ADLIB, Extended Pascal:
program Adhoc; function Add(x, y : Integer) : Integer; begin Add := x + y end; function Add(s, t : String) : String; begin Add := Concat(s, t) end; begin Writeln(Add(1, 2)); (* Prints "3" *) Writeln(Add('Hello, ', 'World!')); (* Prints "Hello, World!" *) end.
Example from Speedie:
function volume (|float| a, |float|) return a*a*a function volume (|float| r, |float| h, |float|) // volume of a cylinder return math.pi*r*r*h

Languages with Function Overloading include C++, Pascal, Speedie, Dale, Real-Time Concurrent C, ADLIB, Extended Pascal

Languages without Function Overloading include JavaScript, Ruby, TypeScript, C3, Jule

This question asks: Can you have multiple functions with the same name but different parameters?

Read more about Function Overloading on the web: 1. 2.

HTML of this page generated by Features.ts

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Queries Stats Sponsor Day 605 feedback@pldb.io Logout