Using a Template Library

A template library is just like any other C++ class library, except that most of the classes in it are template classes.

A template class is like a family of classes that provide the same basic functionality, but operate on mulitple data types. Instead of defining a separate class for each data type, however, you define one class that has one or more formal type parameters. When you instantiate the class, you pass the appropriate data types as the actual parameters. The compiler then expands the class definition, substituting the actual type parameters for the formal type parameters used in the template specification. In this way, template classes provide the benefits of polymorphism without the overhead of traversing a class hierarchy.

By using template classes wherever possible, ATL for Windows CE is able to create smaller, faster components than it could by using inheritance alone, as MFC does. Another difference between ATL and MFC is that ATL makes use of multiple inheritance. Multiple inheritance can be tricky to implement but, when used properly, it provides a way to reuse existing classes more efficiently than you could by using single inheritance alone.

By judiciously combining the advantages of multiple inheritance with the benefits of template classes, ATL for Windows CE helps you create the smallest, fastest, and most efficient COM components and ActiveX controls possible.

You generally include the ATL for Windows CE source code directly in your application, but you can also use it as a shared DLL by linking your application with Atlce.dll.