Thread: Compiling templates

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1

    Question Compiling templates

    hi,
    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
    Posts
    982
    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 -

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

    template.c-
    //definitions

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-18-2005, 12:22 AM
  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