February 2005
Beginner to intermediate
272 pages
4h 53m
English
A generic algorithm is a function template that is designed in such a way that it can be easily and effectively customized at compile time according to the context of its use. Let’s look at a function template that doesn’t meet these exacting standards and is therefore not a proper generic algorithm:

This template can be used to sort an array of objects, provided that the objects can be compared with a < operator and copied. For example, we can sort an array of our String objects from Assignment and Initialization Are Different [12, 41]:
String names[] = { "my", "dog", "has", "fleece" };const int namesLen = sizeof(names)/sizeof(names[0]); ...
Read now
Unlock full access