I'm learning c++ (not my choice) and faced some classes with no .cpp file. I was told that classes should be implemented in 2 files : header file (.h) and source file (.cpp) but it seems it's not always like this. My question is : When and why it is preferred to implement class methods in header file (.h) and when it's not?