Include file conventions

The implementation of your noninline class template methods should be hidden from your clients. Unfortunately, many C++ compilers require that the source of the noninline class template methods implementation be available at the client's compile time. To keep the noninline class template method implementations from cluttering your include file, place them in a separate include file, and #include the separate include file at the end of the regular include file.

If your include file is MyFile.h, name the implementation include file MyFileTemplateMethods.h. (The filename should be MyFileTemplateMethods.C; but the current build tools require header files to end in .h.)

      #ifndef Taligent_MYFILE
      #define Taligent_MYFILE
      
      template <class AType>
      class TMyTemplate { ... };
      
      #ifndef Taligent_MYFILETEMPLATEMETHODS
      #include <MyFileTemplateMethods.h>
      #endif
      
      #endif
      

      #ifndef Taligent_MYFILETEMPLATEMETHODS
      #define Taligent_MYFILETEMPLATEMETHODS
      
      #ifndef Taligent_MYFILE
      #include <MyFile.h>
      #endif
      
      template <class AType>
      TMyTemplate::TMyTemplate() { ... }
      
      #endif

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker