Selecting which implementation of an operation (method or function) to call
Selecting which implementation of an operation (method or function) to call at compile time
Selecting which implementation of an operation (method) to call at run time
pshape
and the reference parameter shape
calls may not exist yetapply()
are compiled so that for any class that inherits from the class Shape, the function calls the proper methodShape*
or a Shape&
, the apply()
functions must call the Shape methods for Shape objects and derived methods for objects of derived classesapply()
code existed and was compiled long before class Circle was createdapply()
code in this case must call Circle::draw()