Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Template Specializations

The C++ idea of a template is based on the assumption that the algorithm works in exactly the same way for different data types. Then writing just one class instead of writing a separate class for each type makes sense. Sometimes, however, this assumption does not hold. The algorithm works the same way for different data types, but for some types, some details of the algorithm have to be implemented differently.

Consider, for example, a template class Array that contains a set of data (of a component type) and allows the client code to check whether a given element (of the component type) can be found in the collection.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial