O'Reilly logo

C++ Common Knowledge: Essential Intermediate Programming by Stephen C. Dewhurst

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Item 2. Polymorphism

The topic of polymorphism is given mystical status in some programming texts and is ignored in others, but it’s a simple, useful concept that the C++ language supports. According to the standard, a “polymorphic type” is a class type that has a virtual function. From the design perspective, a “polymorphic object” is an object with more than one type, and a “polymorphic base class” is a base class that is designed for use by polymorphic objects.

Consider a type of financial option, AmOption, as shown in Figure 1.

Figure 1. Polymorphic leveraging in a financial option hierarchy. An American option has four types.

image

An AmOption ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required