Abstract
Polymorphism is such a powerful feature of object-oriented programming that you’ll use it in the majority of your C++ programs. Polymorphism requires you to use derived classes, so the content of this chapter relies heavily on the concepts related to inheritance in derived classes that we introduced in the previous chapter.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Some compilers don’t enable runtime type identification by default, so if this doesn’t work, look for a compiler option to switch it on.
- 2.
With some popular compilers, we kid you not, you may even notice that typeid() evaluates its operand twice. In our example, that means that the line GetSomeBox() called... might appear twice in the output. This is a bug, of course. But still it’s all the more reason never to apply typeid() to a function call.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2018 Ivor Horton and Peter Van Weert
About this chapter
Cite this chapter
Horton, I., Van Weert, P. (2018). Polymorphism. In: Beginning C++17. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3366-5_14
Download citation
DOI: https://doi.org/10.1007/978-1-4842-3366-5_14
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-3365-8
Online ISBN: 978-1-4842-3366-5
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books