ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

Ad Hoc Polymorphism

Definition - What does Ad Hoc Polymorphism mean?

Ad hoc polymorphism refers to polymorphic functions that can be applied to different argument types known by the same name in a programming language. Ad hoc polymorphism is also known as function overloading or operator overloading because a polymorphic function can represent a number of unique and potentially heterogeneous implementations depending on the type of argument it is applied to.

Techopedia explains Ad Hoc Polymorphism

Ad hoc polymorphism defines operators that can be used for different argument types. It follows a dispatch mechanism in which the control moving from one named function is dispatched to several other functions without specifying the function being called. This function overloading permits multiple functions taking different argument types to be known by the same name as the compiler and interpreter calls the right function. For example in the following code:

 int a, b;
float x, y;
printf(“%d %f”, a+b, x+y);
The symbol ‘+’ is used in two different ways. In the expression a+b, it stands for the function that adds two integers. In the expression x+y, it stands for the function that adds two floats. Thus, ad hoc polymorphism refers to the use of a single function name to indicate two or more unique functions. The compiler decides which function to call depending on the type of arguments.

Ad hoc polymorphism is supported by almost all programming languages for built-in operations such as ‘+’, ‘-‘, ‘*’, etc.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.