Chapter 6. Object-Oriented Programming

C++ is a multi-paradigm language, and the paradigm that is most strongly associated with C++ is Object-Oriented Programming (OOP). As a result, we find all these beautiful dog-cat-mouse examples in books and tutorials. Experience shows, however, that most real software packages do not contain such deep class hierarchies as the literature makes us believe.

It is furthermore our experience that generic programming is the superior paradigm in scientific and engineering programming because

• It is more flexible: polymorphism is not limited to sub-classes; and

• It provides better performance: no overhead in function calls.

We will explain this in more detail within this chapter.

On the other hand, inheritance ...

Get Discovering Modern C++: An Intensive Course for Scientists, Engineers, and Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.