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 template functions and template classes
- Understanding how operator overloading can make templates more extensible
Many object-oriented languages include the concept of programming with generics, allowing the types...