Thread: Compiling templates

  1. #1
    Registered User
    Join Date
    Nov 2001

    Question Compiling templates

    I have a template class declared in a .h file,
    and the implementation in a .C file.
    Is it at all possible to compile the source by including the .C file in the .h?
    Can a .o be created from a template at compile time?
    thanks in advance

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    You can use an include directive to copy the code in the c files to the h file, and then include the h file where it is needed -

    //declarations and any inline definitions
    #include "template.c" //at very end of template.h


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Questions about Templates
    By Shamino in forum C++ Programming
    Replies: 4
    Last Post: 12-17-2005, 11:22 PM
  3. templates and inheritance problem
    By kuhnmi in forum C++ Programming
    Replies: 4
    Last Post: 06-14-2004, 02:46 AM
  4. When and when not to use templates
    By *ClownPimp* in forum C++ Programming
    Replies: 7
    Last Post: 07-20-2003, 09:36 AM
Website Security Test