For some classes, such as exceptions or templates, only a header file (.h) is needed, often there is no .cpp associated with them.
I saw that some projects were (for some classes), there are no .cpp files associated with header files, perhaps because the implementation is so short that it is done directly in .h, or maybe for other reasons, such as classes templates where it is mandatory to include the implementation in the header.
What is your opinion, if the class is too short, can I create a .cpp file and write the code directly in the header file? If the code is written in the header file, should I include an empty .cpp so that the files in the project remain consistent?
c ++ header-files compilation
lurks
source share