Correct way to put template classes in files?

Started by
2 comments, last by DanG 21 years, 6 months ago
What is the correct way to organize files for a templated class with defined functions. I tried the standard .h and .cpp with #include .h, but that caused many compiler errors. What is the correct way?
Ambassador: Mr. Bush are you stoned or just really, REALLY dumb?Pres. Bush - I assure you I am not stoned.
Advertisement
Template class definitions and the member function bodies need to all be placed in the same header file.


The hackers must have gotten into the system through the hyperlink!!

Invader''s Realm
of you can name the file whatever.template, and do #include whatever.template at the bottom of your whatever.h file. That hides the implementation at least a little bit.
For all my templated and normal classes, I put the class definition first, then the inlined/template member functions at the end of the class''s definition. This allows me to include headers needed by the template/inlined member functions after the class definition.

This topic is closed to new replies.

Advertisement