13

Working with Templates

This chapter will continue our pursuit of increasing your C++ programming repertoire beyond OOP concepts, with the continued goal of writing more extensible code. We will next explore creating generic code using C++ templates – both template functions and template classes. We will learn how template code, when written correctly, is the pinnacle in code reuse. In addition to exploring how to create both template functions and template classes, we will also understand how the appropriate use of operator overloading can make a template function reusable for nearly any type of data.

In this chapter, we will cover the following main topics:

  • Exploring template basics to genericize code
  • Understanding how to create and use ...

Get Deciphering Object-Oriented Programming with C++ 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.