15.1 INTRODUCTION TO TEMPLATE

There are many algorithms for sorting. Every programming book contains many programs based on these sorting algorithms. If we are developing an application requiring sorting, we can select a suitable algorithm. However, you must have noticed that all the textbooks contain programs, which sort integers. Our application may require us to sort data of a particular type, say float or even objects of some class.

One possible solution is to modify the function from the text. However, it needs some efforts and open to bugs too! Next day our data may still be of different type. Again modification. Once again possibilities of errors! How many times are we going to modify sorting functions? A real solution to this problem ...

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