Browse Definitions:
Definition

polymorphism

Contributor(s): Jack Ulsh

In object-oriented programming, polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form. There are several different kinds of polymorphism.

1) A variable with a given name may be allowed to have different forms and the program can determine which form of the variable to use at the time of execution. For example, a variable named USERID may be capable of being either an integer (whole number) or a string of characters (perhaps because the programmer wants to allow a user to enter a user ID as either an employee number - an integer - or with a name - a string of characters). By giving the program a way to distinguish which form is being handled in each case, either kind can be recognized and handled.

2) A named function can also vary depending on the parameters it is given. For example, if given a variable that is an integer, the function chosen would be to seek a match against a list of employee numbers; if the variable were a string, it would seek a match against a list of names. In either case, both functions would be known in the program by the same name. This type of polymorphism is sometimes known as overloading.

In C++, for example, the operator known as the plus sign (+) - which is effectively a simple named function - can be assigned to operate on two objects such that it adds them together (perhaps the most common form of the + operation) or, as in boolean searching, a + can indicate a logical "and" (meaning that both words separated by the + operator must be present in order for a citation to be returned). In another context, the + sign could mean an operation to concatenate the two objects or strings of letters on either side of the + sign.

A given operator can also be given yet another meaning when combined with another operator. For example, in the C++ language, a "++" following a variable can mean "increment this value by 1". The meaning of a particular operator is defined as part of a class definition. Since the programmer can create classes, the programmer can also define how operators work for this class of objects; in effect, the programmer can redefine the computing language.

3) Polymorphism can mean, as in the ML language, a data type of "any," such that when specified for a list, a list containing any data types can be processed by a function. (For example, if a function simply determines the length of a list, it doesn't matter what data types are in the list.)

4) In PHP, polymorphism means that if B is a descendant of A and a function can accept A as a parameter, it can also accept B.

This was last updated in April 2005

Continue Reading About polymorphism

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

gud explanation
Cancel

-ADS BY GOOGLE

File Extensions and File Formats

Powered by:

SearchCompliance

  • internal audit (IA)

    An internal audit (IA) is an organizational initiative to monitor and analyze its own business operations in order to determine ...

  • pure risk (absolute risk)

    Pure risk, also called absolute risk, is a category of threat that is beyond human control and has only one possible outcome if ...

  • risk assessment

    Risk assessment is the identification of hazards that could negatively impact an organization's ability to conduct business.

SearchSecurity

  • principle of least privilege (POLP)

    The principle of least privilege (POLP), an important concept in computer security, is the practice of limiting access rights for...

  • identity management (ID management)

    Identity management (ID management) is the organizational process for identifying, authenticating and authorizing individuals or ...

  • zero-day (computer)

    A zero-day vulnerability, also known as a computer zero day, is a flaw in software, hardware or firmware that is unknown to the ...

SearchHealthIT

SearchDisasterRecovery

  • business continuity and disaster recovery (BCDR)

    Business continuity and disaster recovery (BCDR) are closely related practices that describe an organization's preparation for ...

  • business continuity plan (BCP)

    A business continuity plan (BCP) is a document that consists of the critical information an organization needs to continue ...

  • call tree

    A call tree -- sometimes referred to as a phone tree -- is a telecommunications chain for notifying specific individuals of an ...

SearchStorage

  • SAS SSD (Serial-Attached SCSI solid-state drive)

    A SAS SSD (Serial-Attached SCSI solid-state drive) is a NAND flash-based storage or caching device designed to fit in the same ...

  • MTTR (mean time to repair)

    MTTR (mean time to repair) is the average time required to fix a failed component or device and return it to production status.

  • OpenStack Swift

    OpenStack Swift, also known as OpenStack Object Storage, is an open source object storage system that is licensed under the ...

SearchSolidStateStorage

  • hybrid hard disk drive (HDD)

    A hybrid hard disk drive is an electromechanical spinning hard disk that contains some amount of NAND Flash memory.

Close