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
Share this Page URL
Help

Chapter 17. Templates: Yet Another Desig... > Syntax of Template Class Definition

Syntax of Template Class Definition

C++ supports yet another method to reuse class design. This tool is called a template class. Instead of the class with a fixed type of component, you create the class where the type of component is treated as a class parameter.

This parameter has a programmer-defined name, for example, Type, T, Tp, and so on. (As for any parameter, it is up to the programmer to decide what to call it.) Its actual value can be any type, built-in or programmer-defined. As for any parameter, its actual value cannot be known at the time of compiling the template definition. When the client code instantiates an object of this class, it specifies the actual type that should be used in the class instead of the class parameter.


  

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