The implementation of a template class must be contained in the header file where it was defined. Should the implementation of such a class be done in-class or regular (like you would to it with every other class) but just in the header file?
The problem i have with the regular approach is that the implementation becomes very bloated since you need to put the template definition infront. I would like to know which is the most common way though.
Probably the most common way is to write the class definition, then write the implementation in another file, then
#includethe implementation file at the bottom of the header file and don’t list it in the files to be compiled. That way they are in different files but the compiler is satisfied because the definition and declaration is in the same file after preprocessing.Example:
After the preprocessor is done, the file looks like