-1

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 have two basic questions about function templates in c++.

  1. Is it necessary to define template in .h file?
  2. I have created a dll and exported a whole c++ class in that dll. And this class contains a function template. I am calling this template inside a another module that lodes this dll. So when this template related object file will be created.?
Community
  • 1
  • 1
Apoorva sahay
  • 1,900
  • 3
  • 28
  • 45

1 Answers1

2
  1. Almost always. Tons of dups of this part of the question.
  2. The app that's loading the DLL should have already pulled in the template (see #1) so loading at runtime is irrelevant. Also note that C++ ABI is quite finicky and putting a public C++ API into a DLL is asking for all sorts of subtle ABI breakage.
Mark B
  • 95,107
  • 10
  • 109
  • 188