stason.org logo lotus


previous page: 4.2) What are Virtual Functions? (Object-Oriented Technology)page up: Object-Oriented Technology FAQnext 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)

 Books
 TULARC






















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:


Share and Enjoy

Bookmark this story so others can enjoy it:
  • digg
  • Reddit
  • del.icio.us
  • Furl
  • Wists

Tags

programming, software, coding, Object-Oriented, language, dynamic binding, constructor, destructor, overriding, methods, inheritance, reflection, persistence, MFC, real-time, polymorphism, system, database, vendor







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