-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
  • 10,303
  • 14
  • 70
  • 145

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
  • 35,456
  • 20
  • 106
  • 151