14

Generic Programming and Templates

LEARNING OBJECTIVES

At the end of this chapter, you should be able to understand

  • Using template classes employing template class member functions as well as non-template class member functions.

  • Use type-specific friend functions and static member function and data.

  • Use generic programs extensively for data structure implementation such as stack.

  • Appreciate concepts of developing template libraries.

14.1 Introduction

Generic programming means writing programs that will work for any type of data, i.e. make the programs independent of the type of data. With generic programs, there will be no need to develop type-specific programs for each data type. Templates in C++ are implementation tools provided to ...

Get Object-oriented Programming Using C++ and Java 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.