0

Possible Duplicate:
Why can templates only be implemented in the header file?
Why should the implementation and the declaration of a template class be in the same header file?

I am going to create a couple of ADTs and compare their performance(I am taking a data structures course and want to experiment;note: our instructor uses Java). I want to create generic classes so that I am not stuck with a particular datatype. I read a long time ago that it is not possible to split templated classes. What is the best approach to keep the code clean? The most obvious approach is to simple uses .cpp files without hiding implementation, such as in java. Is there any other approach that I could use?

Community
  • 1
  • 1
devjeetroy
  • 1,855
  • 6
  • 26
  • 43

1 Answers1

5

Some people use an "ipp" file that is included by the header.

Besides something like that...it is what it is. You can't put template code in a compiled file and have it available outside of it.

Edward Strange
  • 40,307
  • 7
  • 73
  • 125
  • 1
    .inl (for inline) is also a common extension for files included directly in an .h file, but that aren't meant to be included by other .h/.cpps. – Dan O May 06 '12 at 02:24
  • I've only seen .hpp for C++ headers that you DO include. All of boost is done that way, but they use .ipp for implementations sometimes. – Edward Strange May 06 '12 at 04:40