Templates

Is it possible to put a class/function template definition in a header file and then include the file in the cpp files that use the template?
No easy way with the current standard.

There are tricks to accomplish it with instantiating the templates you need, but I never really understood how it worked completely, and it's errorprone anyway.

What I do instead, when I want to have a seperate file, is I just make a "blah.hpp" file for the implementation (vs a "blah.h" for the header), and #include the .hpp at the end of the .h. This allows me to keep them seperated, but still avoid the linker errors.

If you're interested about the instantiating method, I can refer you to this page:

http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12
Yes, but you MUST include the definition in the header file as well. You can't make a "template prototype."
OK, thanks :)
Topic archived. No new replies allowed.