Question: So, I heard that C++ templates shouldn't be separated into a header (.h) and source (.cpp) files.

For instance, a template like this:

```
template <class T>
class J
{   
   T something;
};

```

Is this true? Why is it so?

If because of that I'm gonna have to put both declaration and implementation in the same file, should I put it in a .h file or a .cpp file?

Answer: 
Headers.

It's because templates are instantiated at compile-time, not link-time, and different translation units (roughly equivalent to your `.cpp` files) only "know about" each other at link-time. Headers tend to be widely "known about" at compile-time because you `#include` them in any translation unit that needs them.

Read <https://isocpp.org/wiki/faq/templates> for more.
If you need the template code to be usable by other translation units (.cpp files), you need to put the implementation in the .h file or else those other units won't be able to instantiate the template (expand it according to the types they use).

If your template function is only instantiated in one .cpp file, you can define it there. This happens sometimes when a class has a private member function which is a template (and it is only called from the implementation file, not the class header file).