Quote:Original post by RaptorZero
Damn compiler forcing me to include a cpp file...
The compiler doesn't know the difference between a .h and a .cpp file. As far as it is concerned, a file is a file. When you #include something, the contents of the file included get merged into the stream of data that is sent to the compiler.
The thing with templates is that, just like inline functions, their code must be accessible from the point where they are used, since it is when the compiler is going to turn the template into "real" non-template code.
Which is why templates are always* kept in header files if they are going to be shared by multiple source files.
* - well, almost always.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan