lotus

previous page: 4.2) What are Virtual Functions? (Object-Oriented Technology)
  
page up: Object-Oriented Technology FAQ
  
next page: 4.4) Can I Use Dynamic Inheritance In C++? (Object-Oriented Technology)

4.3) Can I Use Multiple-Polymorphism Or Multi-Methods In C++? (Object-Oriented Technology)




Description

This article is from the Object-Oriented Technology FAQ, by Bob Hathaway rjh@geodesic.com with numerous contributions by others.

4.3) Can I Use Multiple-Polymorphism Or Multi-Methods In C++? (Object-Oriented Technology)

Yes, but you'll need to embed a dynamic typing scheme to do it. With dynamic
types in place, an overriding method in a derived class can explicitly check
argument types in a switch statement and invoke the desired method emulating
multiple-polymorphism [See Coplien 92].

For true CLOS multi-methods, the above technique implemented as a base function
(CLOS defgeneric), switching to specialized functions (CLOS methods, made
friends of all arguments) will provide the functional calling syntax, multiple-
polymorphism and access to parameters found in CLOS. This can require some
complex switching, which is somewhat mitigated when multiple-polymorphism
is implemented with virtual functions.

Future FAQs should contain more detail.

 

Continue to:













TOP
previous page: 4.2) What are Virtual Functions? (Object-Oriented Technology)
  
page up: Object-Oriented Technology FAQ
  
next page: 4.4) Can I Use Dynamic Inheritance In C++? (Object-Oriented Technology)