-1

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

I'm not really understand why it's olbiged to define template implementation in a .h file?

Could someone give me a detail answer ?

Thanks!

Community
  • 1
  • 1
Guillaume Paris
  • 9,916
  • 14
  • 65
  • 136

1 Answers1

0

Because the compiler needs the code to instantiate the template. If you put a template implementation into a .cpp file, you will be only able to instantiate the template in that .cpp file.

Šimon Tóth
  • 34,358
  • 19
  • 97
  • 147