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.
Get Core C++ A Software Engineering Approach 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.