1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is polymorphism?
The ability to treat values, objects, or functions of different types in a uniform way while allowing different behaviors
What are the two main categories of polymorphism?
Ad-hoc polymorphism
Universal polymorphism
What are the two forms of ad-hoc polymorphism?
Coercion
Overloading
What is coercion polymorphism?
Automatic conversion from one type to another.
Example: int -> double or double -> int
What is overloading polymorphism?
Using the same function or operator name with different parameter lists
What are the two forms of universal polymorphism?
Inclusion
Parametric
What is inclusion polymorphism?
Using inheritance and virtual functions so different derived objects can be treated through a common base class
How is inclusion polymorphism commonly implemented?
Using base-class pointers or references that point to derived-class objects
What operator is commonly used to invoke late binding through a base-class pointer?
ptr->virtualFunction();What is parametric polymorphism?
Polymorphism implemented using templates so the same code works with many types
What are the benefits of templates?
Code reuse
Type safety
Less repetitive code
What is early binding (static binding)?
Function calls are resolved at compile time
What is late binding (dynamic dispatch)?
Function calls are resolved at runtime
Which polymorphism types use early binding?
Coercion
Overloading
Parametric polymorphism
Which polymorphism type uses late binding?
Inclusion polymorphism